Skip to content

Commit

Permalink
[MIG] l10n_it_accompanying_invoice: Migration to 16.0
Browse files Browse the repository at this point in the history
Co-authored-by: Simone Rubino <[email protected]>
Co-authored-by: OdooNextev <[email protected]>
  • Loading branch information
2 people authored and OCA-git-bot committed Dec 20, 2024
1 parent 670e7ec commit 19bfacc
Show file tree
Hide file tree
Showing 23 changed files with 821 additions and 140 deletions.
20 changes: 20 additions & 0 deletions l10n_it_accompanying_invoice/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ Valorizzare i campi del foglio *Informazioni di spedizione*.
Usare l'azione *Fattura accompagnatoria* all'interno della lista di
azioni *Stampa*, nella vista delle fatture.

Known issues / Roadmap
======================

**Italiano**

Odoo Italia non supporta più i moduli alla versione 12.0 perciò non ci
siamo occupati ufficialmente della migrazione dei dati da questa
versione.

Tuttavia se non si volessero perdere i dati già presenti nella versione
12.0 si può provare in un ambiente di test la procedura di migrazione a
proprio rischio e non garantita togliendo la dipendenza dal modulo
``l10n_it_ddt`` nel ``__manifest__.py`` e lanciando gli script di
migrazione commentati. Passaggi:

- decommentare il riferimento a ``hooks.py`` in ``__init__.py``
- decommentare ``external_dependencies`` e ``pre_init_hook`` in
``__manifest__.py``
- spostare la cartella ``readme/migrations`` nella root del modulo

Bug Tracker
===========

Expand Down
1 change: 1 addition & 0 deletions l10n_it_accompanying_invoice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
# from .hooks import pre_absorb_old_module
13 changes: 10 additions & 3 deletions l10n_it_accompanying_invoice/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Copyright 2017 Lorenzo Battistini - Agile Business Group
# Copyright 2020 Simone Vanin - Agile Business Group
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "ITA - Fattura accompagnatoria",
"summary": "Stampa della fattura accompagnatoria",
"version": "12.0.1.0.0",
"version": "16.0.1.0.1",
"category": "Accounting",
"website": "https://github.com/OCA/l10n-italy"
"/tree/12.0/l10n_it_accompanying_invoice",
"/tree/16.0/l10n_it_accompanying_invoice",
"author": "Agile Business Group, " "Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"l10n_it_ddt",
"l10n_it_delivery_note",
],
"data": [
"views/account.xml",
"views/report_invoice.xml",
],
# "external_dependencies": {
# "python": [
# "openupgradelib",
# ],
# },
# "pre_init_hook": "pre_absorb_old_module",
}
225 changes: 225 additions & 0 deletions l10n_it_accompanying_invoice/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
# Copyright 2023 Simone Rubino - Aion Tech
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

from odoo.tools import DotDict

RENAMED_FIELDS = [
[
(
"account.invoice",
"note",
),
(
"account.move",
"delivery_note",
),
],
[
(
"account.invoice",
"date_done",
),
(
"account.move",
"delivery_transport_datetime",
),
],
[
(
"account.invoice",
"carriage_condition_id",
),
(
"account.move",
"delivery_transport_condition_id",
),
],
[
(
"account.invoice",
"goods_description_id",
),
(
"account.move",
"delivery_goods_appearance_id",
),
],
[
(
"account.invoice",
"transportation_reason_id",
),
(
"account.move",
"delivery_transport_reason_id",
),
],
[
(
"account.invoice",
"transportation_method_id",
),
(
"account.move",
"delivery_transport_method_id",
),
],
[
(
"account.invoice",
"carrier_id",
),
(
"account.move",
"delivery_carrier_id",
),
],
[
(
"account.invoice",
"parcels",
),
(
"account.move",
"delivery_packages",
),
],
[
(
"account.invoice",
"weight",
),
(
"account.move",
"delivery_net_weight",
),
],
[
(
"account.invoice",
"gross_weight",
),
(
"account.move",
"delivery_gross_weight",
),
],
[
(
"account.invoice",
"volume",
),
(
"account.move",
"delivery_volume",
),
],
[
(
"account.invoice",
"weight_manual_uom_id",
),
(
"account.move",
"delivery_net_weight_uom_id",
),
],
[
(
"account.invoice",
"gross_weight_uom_id",
),
(
"account.move",
"delivery_gross_weight_uom_id",
),
],
[
(
"account.invoice",
"volume_uom_id",
),
(
"account.move",
"delivery_volume_uom_id",
),
],
]

RENAMED_XMLIDS = [
(
"invoice_form_view_uom",
"view_move_form",
),
(
"invoice_form_view_uom",
"shipping_invoice_report",
),
(
"invoice_form_view_uom",
"shipping_invoice_template",
),
(
"invoice_form_view_uom",
"report_shipping_invoice",
),
]


# def remove_models(cr, model_spec):
# for name in model_spec:
# logged_query(
# cr,
# "DELETE FROM ir_model WHERE model = %s",
# (name,),
# )


def migrate_old_module(cr):
field_spec = []
for renamed_field in RENAMED_FIELDS:
(old_model, old_field), (new_model, new_field) = renamed_field
field_spec.append(
(
old_model,
old_model.replace(".", "_"),
old_field,
new_field,
)
)
openupgrade.rename_fields(
# The method only needs the cursor, not the whole Environment
DotDict(
cr=cr,
),
field_spec,
# Prevent Environment usage
# whenever it will be implemented.
no_deep=True,
)

full_renamed_xmlids = [
(
".".join(("l10n_it_accompanying_invoice", old_xmlid)),
".".join(("l10n_it_accompanying_invoice", new_xmlid)),
)
for old_xmlid, new_xmlid in RENAMED_XMLIDS
]
openupgrade.rename_xmlids(
cr,
full_renamed_xmlids,
)


def pre_absorb_old_module(cr):
if openupgrade.is_module_installed(cr, "l10n_it_accompanying_invoice"):
openupgrade.update_module_names(
cr,
[
("l10n_it_fattura_accompagnatoria", "l10n_it_accompanying_invoice"),
],
merge_modules=True,
)
migrate_old_module(cr)
Loading

0 comments on commit 19bfacc

Please sign in to comment.