From 37862c6948a7faf4e231900cf23fd1c3d558e468 Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Mon, 20 Nov 2023 11:59:15 +0100 Subject: [PATCH] [MIG] l10n_it_accompanying_invoice: Migration to 16.0 --- l10n_it_accompanying_invoice/i18n/it.po | 46 ----- .../i18n/l10n_it_accompanying_invoice.pot | 35 ---- .../models/account_invoice.py | 13 -- .../tests/test_report.py | 17 -- .../views/account.xml | 15 -- .../views/report_invoice.xml | 37 ---- .../README.rst | 13 +- .../__init__.py | 1 + .../__manifest__.py | 13 +- l10n_it_shipping_invoice/hooks.py | 89 +++++++++ l10n_it_shipping_invoice/i18n/it.po | 181 ++++++++++++++++++ .../migrations/16.0.1.0.0/pre-migrate.py | 14 ++ .../models/__init__.py | 3 +- .../models/account_move.py | 35 ++++ l10n_it_shipping_invoice/models/sale_order.py | 21 ++ .../pyproject.toml | 0 .../readme/CONTRIBUTORS.md | 0 .../readme/DESCRIPTION.md | 0 l10n_it_shipping_invoice/readme/ROADMAP.md | 1 + .../readme/USAGE.md | 0 .../static/description/icon.png | Bin .../static/description/index.html | 31 +-- .../tests/__init__.py | 2 + .../tests/test_account_move.py | 52 +++++ l10n_it_shipping_invoice/tests/test_report.py | 21 ++ .../tests/test_sale_order.py | 82 ++++++++ l10n_it_shipping_invoice/views/account.xml | 87 +++++++++ .../views/report_invoice.xml | 48 +++++ .../odoo/addons/l10n_it_accompanying_invoice | 1 - .../odoo/addons/l10n_it_shipping_invoice | 1 + .../setup.py | 0 31 files changed, 674 insertions(+), 185 deletions(-) delete mode 100644 l10n_it_accompanying_invoice/i18n/it.po delete mode 100644 l10n_it_accompanying_invoice/i18n/l10n_it_accompanying_invoice.pot delete mode 100644 l10n_it_accompanying_invoice/models/account_invoice.py delete mode 100644 l10n_it_accompanying_invoice/tests/test_report.py delete mode 100644 l10n_it_accompanying_invoice/views/account.xml delete mode 100644 l10n_it_accompanying_invoice/views/report_invoice.xml rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/README.rst (88%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/__init__.py (67%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/__manifest__.py (68%) create mode 100644 l10n_it_shipping_invoice/hooks.py create mode 100644 l10n_it_shipping_invoice/i18n/it.po create mode 100644 l10n_it_shipping_invoice/migrations/16.0.1.0.0/pre-migrate.py rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/models/__init__.py (55%) create mode 100644 l10n_it_shipping_invoice/models/account_move.py create mode 100644 l10n_it_shipping_invoice/models/sale_order.py rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/pyproject.toml (100%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/readme/CONTRIBUTORS.md (100%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/readme/DESCRIPTION.md (100%) create mode 100644 l10n_it_shipping_invoice/readme/ROADMAP.md rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/readme/USAGE.md (100%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/static/description/icon.png (100%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/static/description/index.html (86%) rename {l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/tests/__init__.py (59%) create mode 100644 l10n_it_shipping_invoice/tests/test_account_move.py create mode 100644 l10n_it_shipping_invoice/tests/test_report.py create mode 100644 l10n_it_shipping_invoice/tests/test_sale_order.py create mode 100644 l10n_it_shipping_invoice/views/account.xml create mode 100644 l10n_it_shipping_invoice/views/report_invoice.xml delete mode 120000 setup/l10n_it_accompanying_invoice/odoo/addons/l10n_it_accompanying_invoice create mode 120000 setup/l10n_it_shipping_invoice/odoo/addons/l10n_it_shipping_invoice rename setup/{l10n_it_accompanying_invoice => l10n_it_shipping_invoice}/setup.py (100%) diff --git a/l10n_it_accompanying_invoice/i18n/it.po b/l10n_it_accompanying_invoice/i18n/it.po deleted file mode 100644 index dac33aa85015..000000000000 --- a/l10n_it_accompanying_invoice/i18n/it.po +++ /dev/null @@ -1,46 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * l10n_it_accompanying_invoice -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-10-14 10:04+0000\n" -"PO-Revision-Date: 2020-10-14 10:04+0000\n" -"Last-Translator: <>\n" -"Language-Team: \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: l10n_it_accompanying_invoice -#: model:ir.actions.report,name:l10n_it_accompanying_invoice.accompanying_invoice_report -msgid "Accompanying Invoice" -msgstr "Fattura accompagnatoria" - -#. module: l10n_it_accompanying_invoice -#: model:ir.model,name:l10n_it_accompanying_invoice.model_account_invoice -msgid "Invoice" -msgstr "Fattura" - -#. module: l10n_it_accompanying_invoice -#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_invoice__note -msgid "Notes" -msgstr "Note" - -#. module: l10n_it_accompanying_invoice -#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_invoice__date_done -msgid "Shipping Date" -msgstr "Data spedizione" - -#~ msgid "Gross Weight UoM" -#~ msgstr "UdM peso lordo" - -#~ msgid "Net Weight UoM" -#~ msgstr "UdM peso netto" - -#~ msgid "Volume UoM" -#~ msgstr "UdM volume" diff --git a/l10n_it_accompanying_invoice/i18n/l10n_it_accompanying_invoice.pot b/l10n_it_accompanying_invoice/i18n/l10n_it_accompanying_invoice.pot deleted file mode 100644 index af4d59f6020a..000000000000 --- a/l10n_it_accompanying_invoice/i18n/l10n_it_accompanying_invoice.pot +++ /dev/null @@ -1,35 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * l10n_it_accompanying_invoice -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: l10n_it_accompanying_invoice -#: model:ir.actions.report,name:l10n_it_accompanying_invoice.accompanying_invoice_report -msgid "Accompanying Invoice" -msgstr "" - -#. module: l10n_it_accompanying_invoice -#: model:ir.model,name:l10n_it_accompanying_invoice.model_account_invoice -msgid "Invoice" -msgstr "" - -#. module: l10n_it_accompanying_invoice -#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_invoice__note -msgid "Notes" -msgstr "" - -#. module: l10n_it_accompanying_invoice -#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_invoice__date_done -msgid "Shipping Date" -msgstr "" - diff --git a/l10n_it_accompanying_invoice/models/account_invoice.py b/l10n_it_accompanying_invoice/models/account_invoice.py deleted file mode 100644 index 96bfe036eb5d..000000000000 --- a/l10n_it_accompanying_invoice/models/account_invoice.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2017 Lorenzo Battistini - Agile Business Group -# Copyright 2020 Simone Vanin - Agile Business Group -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). - - -from odoo import fields, models - - -class AccountInvoice(models.Model): - _inherit = "account.invoice" - # we need this to be able to call l10n_it_ddt.delivery_data - note = fields.Text("Notes", readonly=True, related="comment") - date_done = fields.Datetime(string="Shipping Date") diff --git a/l10n_it_accompanying_invoice/tests/test_report.py b/l10n_it_accompanying_invoice/tests/test_report.py deleted file mode 100644 index 3ad0dbba8608..000000000000 --- a/l10n_it_accompanying_invoice/tests/test_report.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2020 Simone Vanin - Agile Business Group -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -import odoo.tests - - -class TestReport(odoo.tests.TransactionCase): - def test_report(self): - report = self.env["ir.actions.report"]._get_report_from_name( - "l10n_it_accompanying_invoice.accompanying_invoice_template" - ) - - partner1 = self.env.ref("base.res_partner_1") - invoice = self.env["account.invoice"].create({"partner_id": partner1.id}) - - html = report.render_qweb_html([invoice.id]) - - self.assertTrue(html) diff --git a/l10n_it_accompanying_invoice/views/account.xml b/l10n_it_accompanying_invoice/views/account.xml deleted file mode 100644 index daef141f6231..000000000000 --- a/l10n_it_accompanying_invoice/views/account.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - account.invoice.form.ddt.uom - account.invoice - - - - - - - - diff --git a/l10n_it_accompanying_invoice/views/report_invoice.xml b/l10n_it_accompanying_invoice/views/report_invoice.xml deleted file mode 100644 index 38aa953ae9a0..000000000000 --- a/l10n_it_accompanying_invoice/views/report_invoice.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - diff --git a/l10n_it_accompanying_invoice/README.rst b/l10n_it_shipping_invoice/README.rst similarity index 88% rename from l10n_it_accompanying_invoice/README.rst rename to l10n_it_shipping_invoice/README.rst index a6d2b68d84b6..baa7a18df0fa 100644 --- a/l10n_it_accompanying_invoice/README.rst +++ b/l10n_it_shipping_invoice/README.rst @@ -17,10 +17,10 @@ ITA - Fattura accompagnatoria :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github - :target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_accompanying_invoice + :target: https://github.com/OCA/l10n-italy/tree/16.0/l10n_it_shipping_invoice :alt: OCA/l10n-italy .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_accompanying_invoice + :target: https://translation.odoo-community.org/projects/l10n-italy-16-0/l10n-italy-16-0-l10n_it_shipping_invoice :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-italy&target_branch=16.0 @@ -51,13 +51,18 @@ 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 +====================== + +The migration script hasn't been tested. + Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -88,6 +93,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/l10n-italy `_ project on GitHub. +This module is part of the `OCA/l10n-italy `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_accompanying_invoice/__init__.py b/l10n_it_shipping_invoice/__init__.py similarity index 67% rename from l10n_it_accompanying_invoice/__init__.py rename to l10n_it_shipping_invoice/__init__.py index 31660d6a9650..44e4267a3b6f 100644 --- a/l10n_it_accompanying_invoice/__init__.py +++ b/l10n_it_shipping_invoice/__init__.py @@ -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 diff --git a/l10n_it_accompanying_invoice/__manifest__.py b/l10n_it_shipping_invoice/__manifest__.py similarity index 68% rename from l10n_it_accompanying_invoice/__manifest__.py rename to l10n_it_shipping_invoice/__manifest__.py index 19fb49ff3b41..ce69d331c1c6 100644 --- a/l10n_it_accompanying_invoice/__manifest__.py +++ b/l10n_it_shipping_invoice/__manifest__.py @@ -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.0", "category": "Accounting", "website": "https://github.com/OCA/l10n-italy" - "/tree/12.0/l10n_it_accompanying_invoice", + "/tree/16.0/l10n_it_shipping_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", } diff --git a/l10n_it_shipping_invoice/hooks.py b/l10n_it_shipping_invoice/hooks.py new file mode 100644 index 000000000000..1ba2b40c54cf --- /dev/null +++ b/l10n_it_shipping_invoice/hooks.py @@ -0,0 +1,89 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade +from openupgradelib.openupgrade import logged_query + +from odoo.tools import DotDict + +NEW_MODULE_NAME = "l10n_it_accompanying_invoice" +OLD_MODULE_NAME = "l10n_it_shipping_invoice" + +RENAMED_FIELDS = [ + ( + "account.move", + "account_move", + "note", + "delivery_note", + ), + ( + "account.move", + "account_move", + "date_done", + "delivery_transport_datetime", + ), +] + +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): + openupgrade.rename_fields( + # The method only needs the cursor, not the whole Environment + DotDict( + cr=cr, + ), + RENAMED_FIELDS, + # Prevent Environment usage + # whenever it will be implemented. + no_deep=True, + ) + full_renamed_xmlids = [ + ( + ".".join((NEW_MODULE_NAME, old_xmlid)), + ".".join((NEW_MODULE_NAME, 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, OLD_MODULE_NAME): + openupgrade.update_module_names( + cr, + [ + (OLD_MODULE_NAME, NEW_MODULE_NAME), + ], + merge_modules=True, + ) + migrate_old_module(cr) diff --git a/l10n_it_shipping_invoice/i18n/it.po b/l10n_it_shipping_invoice/i18n/it.po new file mode 100644 index 000000000000..445f51389b05 --- /dev/null +++ b/l10n_it_shipping_invoice/i18n/it.po @@ -0,0 +1,181 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_shipping_invoice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-11-28 08:52+0000\n" +"PO-Revision-Date: 2023-11-28 08:52+0000\n" +"Last-Translator: Simone Rubino \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_it_shipping_invoice +#: model:ir.actions.report,print_report_name:l10n_it_shipping_invoice.shipping_invoice_report +msgid "(object._get_report_base_filename())" +msgstr "" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_goods_appearance_id +msgid "Appearance of goods of Delivery" +msgstr "Aspetto dei beni della consegna" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Carrier" +msgstr "Vettore" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_carrier_id +msgid "Carrier of Delivery" +msgstr "Vettore della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_transport_condition_id +msgid "Condition of transport of Delivery" +msgstr "Condizione di trasporto della consegna" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Goods Appearance" +msgstr "Aspetto dei beni" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Gross Weight" +msgstr "Peso lordo" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_gross_weight +msgid "Gross Weight of Delivery" +msgstr "Peso lordo della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_gross_weight_uom_id +msgid "Gross Weight of Delivery UoM" +msgstr "UdM del peso lordo della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_note +msgid "Internal note of delivery" +msgstr "Note interne della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model,name:l10n_it_shipping_invoice.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_transport_method_id +msgid "Method of transport of Delivery" +msgstr "Metodo di trasporto della consegna" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Net Weight" +msgstr "Peso netto" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_net_weight +msgid "Net Weight of Delivery" +msgstr "Peso netto della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_net_weight_uom_id +msgid "Net Weight of Delivery UoM" +msgstr "UdM del peso netto della consegna" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Note" +msgstr "" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Other" +msgstr "Altro" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Packages" +msgstr "Pacchi" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_packages +msgid "Packages of Delivery" +msgstr "Pacchi della consegna" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Parcels" +msgstr "Colli" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_transport_reason_id +msgid "Reason of transport of Delivery" +msgstr "Causale di trasporto della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model,name:l10n_it_shipping_invoice.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Shipping Information" +msgstr "Informazioni di spedizione" + +#. module: l10n_it_shipping_invoice +#: model:ir.actions.report,name:l10n_it_shipping_invoice.shipping_invoice_report +msgid "Shipping Invoice" +msgstr "Fattura accompagnatoria" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Transport" +msgstr "Trasporto" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Transport Condition" +msgstr "Condizione di trasporto" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Transport Date" +msgstr "Data di trasporto" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_transport_datetime +msgid "Transport Date of Delivery" +msgstr "Data di trasporto della consegna" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Transport Method" +msgstr "Metodo di trasporto" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Transport Reason" +msgstr "Causale di trasporto" + +#. module: l10n_it_shipping_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_shipping_invoice.view_move_form +msgid "Volume" +msgstr "" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_volume +msgid "Volume of Delivery" +msgstr "Volume della consegna" + +#. module: l10n_it_shipping_invoice +#: model:ir.model.fields,field_description:l10n_it_shipping_invoice.field_account_move__delivery_volume_uom_id +msgid "Volume of Delivery UoM" +msgstr "UdM del volume della consegna" diff --git a/l10n_it_shipping_invoice/migrations/16.0.1.0.0/pre-migrate.py b/l10n_it_shipping_invoice/migrations/16.0.1.0.0/pre-migrate.py new file mode 100644 index 000000000000..84cb7439a227 --- /dev/null +++ b/l10n_it_shipping_invoice/migrations/16.0.1.0.0/pre-migrate.py @@ -0,0 +1,14 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +# Pylint disabled because relative might be +# from ... import hooks +# but it raises +# > ImportError: attempted relative import with no known parent package +# pylint: disable=odoo-addons-relative-import +from odoo.addons.l10n_it_shipping_invoice import hooks + + +def migrate(cr, installed_version): + # Used by OpenUpgrade when module is in `apriori` + hooks.migrate_old_module(cr) diff --git a/l10n_it_accompanying_invoice/models/__init__.py b/l10n_it_shipping_invoice/models/__init__.py similarity index 55% rename from l10n_it_accompanying_invoice/models/__init__.py rename to l10n_it_shipping_invoice/models/__init__.py index 3a3cf6bb90b0..cdfc45e0277d 100644 --- a/l10n_it_accompanying_invoice/models/__init__.py +++ b/l10n_it_shipping_invoice/models/__init__.py @@ -1,3 +1,4 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from . import account_invoice +from . import account_move +from . import sale_order diff --git a/l10n_it_shipping_invoice/models/account_move.py b/l10n_it_shipping_invoice/models/account_move.py new file mode 100644 index 000000000000..ff71322c00fb --- /dev/null +++ b/l10n_it_shipping_invoice/models/account_move.py @@ -0,0 +1,35 @@ +# 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). + + +from odoo import api, models + + +class AccountMove(models.Model): + _name = "account.move" + _inherit = [ + "account.move", + "l10n_it_delivery_note.delivery_mixin", + ] + + @api.onchange( + "partner_id", + ) + def _onchange_partner_shipping_data(self): + for invoice in self: + partner = invoice.partner_id + if partner: + invoice.delivery_transport_reason_id = ( + partner.default_transport_reason_id + ) + invoice.delivery_transport_condition_id = ( + partner.default_transport_condition_id + ) + invoice.delivery_transport_method_id = ( + partner.default_transport_method_id + ) + invoice.delivery_goods_appearance_id = ( + partner.default_goods_appearance_id + ) diff --git a/l10n_it_shipping_invoice/models/sale_order.py b/l10n_it_shipping_invoice/models/sale_order.py new file mode 100644 index 000000000000..1f5e633a78bd --- /dev/null +++ b/l10n_it_shipping_invoice/models/sale_order.py @@ -0,0 +1,21 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _prepare_invoice(self): + invoice_values = super()._prepare_invoice() + default_transport_condition = self.default_transport_condition_id + invoice_values.update( + { + "delivery_transport_condition_id": default_transport_condition.id, + "delivery_goods_appearance_id": self.default_goods_appearance_id.id, + "delivery_transport_reason_id": self.default_transport_reason_id.id, + "delivery_transport_method_id": self.default_transport_method_id.id, + } + ) + return invoice_values diff --git a/l10n_it_accompanying_invoice/pyproject.toml b/l10n_it_shipping_invoice/pyproject.toml similarity index 100% rename from l10n_it_accompanying_invoice/pyproject.toml rename to l10n_it_shipping_invoice/pyproject.toml diff --git a/l10n_it_accompanying_invoice/readme/CONTRIBUTORS.md b/l10n_it_shipping_invoice/readme/CONTRIBUTORS.md similarity index 100% rename from l10n_it_accompanying_invoice/readme/CONTRIBUTORS.md rename to l10n_it_shipping_invoice/readme/CONTRIBUTORS.md diff --git a/l10n_it_accompanying_invoice/readme/DESCRIPTION.md b/l10n_it_shipping_invoice/readme/DESCRIPTION.md similarity index 100% rename from l10n_it_accompanying_invoice/readme/DESCRIPTION.md rename to l10n_it_shipping_invoice/readme/DESCRIPTION.md diff --git a/l10n_it_shipping_invoice/readme/ROADMAP.md b/l10n_it_shipping_invoice/readme/ROADMAP.md new file mode 100644 index 000000000000..26fb54b0cc5a --- /dev/null +++ b/l10n_it_shipping_invoice/readme/ROADMAP.md @@ -0,0 +1 @@ +The migration script hasn't been tested. diff --git a/l10n_it_accompanying_invoice/readme/USAGE.md b/l10n_it_shipping_invoice/readme/USAGE.md similarity index 100% rename from l10n_it_accompanying_invoice/readme/USAGE.md rename to l10n_it_shipping_invoice/readme/USAGE.md diff --git a/l10n_it_accompanying_invoice/static/description/icon.png b/l10n_it_shipping_invoice/static/description/icon.png similarity index 100% rename from l10n_it_accompanying_invoice/static/description/icon.png rename to l10n_it_shipping_invoice/static/description/icon.png diff --git a/l10n_it_accompanying_invoice/static/description/index.html b/l10n_it_shipping_invoice/static/description/index.html similarity index 86% rename from l10n_it_accompanying_invoice/static/description/index.html rename to l10n_it_shipping_invoice/static/description/index.html index 7edec3812e05..b1934a9f711e 100644 --- a/l10n_it_accompanying_invoice/static/description/index.html +++ b/l10n_it_shipping_invoice/static/description/index.html @@ -368,7 +368,7 @@

ITA - Fattura accompagnatoria

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:47e2b4ae93928006b62502df808ccab3b5f961ed66ec2be01da41807a4c16011 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runboat

Italiano

Questo modulo consente di stampare una fattura accompagnatoria, per visualizzare i dati di Informazioni di spedizione nella fattura.

@@ -379,11 +379,12 @@

ITA - Fattura accompagnatoria

+
+

Known issues / Roadmap

+

The migration script hasn’t been tested.

+
-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Agile Business Group
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/l10n-italy project on GitHub.

+

This module is part of the OCA/l10n-italy project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/l10n_it_accompanying_invoice/tests/__init__.py b/l10n_it_shipping_invoice/tests/__init__.py similarity index 59% rename from l10n_it_accompanying_invoice/tests/__init__.py rename to l10n_it_shipping_invoice/tests/__init__.py index 02415651fe44..37126205f1b9 100644 --- a/l10n_it_accompanying_invoice/tests/__init__.py +++ b/l10n_it_shipping_invoice/tests/__init__.py @@ -1,3 +1,5 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_account_move from . import test_report +from . import test_sale_order diff --git a/l10n_it_shipping_invoice/tests/test_account_move.py b/l10n_it_shipping_invoice/tests/test_account_move.py new file mode 100644 index 000000000000..125c8df2e953 --- /dev/null +++ b/l10n_it_shipping_invoice/tests/test_account_move.py @@ -0,0 +1,52 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestAccountMove(AccountTestInvoicingCommon): + def test_propagate_partner_values(self): + """Create an invoice for a partner, + shipping values are propagated from the partner to the invoice.""" + # Arrange + partner = self.env.ref("base.res_partner_1") + partner.default_transport_condition_id = self.env.ref( + "l10n_it_delivery_note_base.transport_condition_PF" + ) + partner.default_goods_appearance_id = self.env.ref( + "l10n_it_delivery_note_base.goods_appearance_CAR" + ) + partner.default_transport_reason_id = self.env.ref( + "l10n_it_delivery_note_base.transport_reason_VEN" + ) + partner.default_transport_method_id = self.env.ref( + "l10n_it_delivery_note_base.transport_method_MIT" + ) + + # Act + invoice = self.init_invoice( + "out_invoice", + partner=partner, + ) + + # Assert + self.assertEqual( + invoice.delivery_transport_condition_id, + partner.default_transport_condition_id, + ) + self.assertEqual( + invoice.delivery_goods_appearance_id, + partner.default_goods_appearance_id, + ) + self.assertEqual( + invoice.delivery_transport_reason_id, + partner.default_transport_reason_id, + ) + self.assertEqual( + invoice.delivery_transport_method_id, + partner.default_transport_method_id, + ) diff --git a/l10n_it_shipping_invoice/tests/test_report.py b/l10n_it_shipping_invoice/tests/test_report.py new file mode 100644 index 000000000000..620587b60510 --- /dev/null +++ b/l10n_it_shipping_invoice/tests/test_report.py @@ -0,0 +1,21 @@ +# 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). + +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestReport(AccountTestInvoicingCommon): + def test_report(self): + invoice = self.init_invoice( + "out_invoice", + ) + + html = self.env["ir.actions.report"]._render_qweb_html( + "l10n_it_shipping_invoice.shipping_invoice_template", + [invoice.id], + ) + self.assertTrue(html) diff --git a/l10n_it_shipping_invoice/tests/test_sale_order.py b/l10n_it_shipping_invoice/tests/test_sale_order.py new file mode 100644 index 000000000000..5e95115e07cd --- /dev/null +++ b/l10n_it_shipping_invoice/tests/test_sale_order.py @@ -0,0 +1,82 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests import Form, tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +def _init_sale_order(env, partner, products): + sale_order_form = Form(env["sale.order"]) + sale_order_form.partner_id = partner + for product in products: + with sale_order_form.order_line.new() as line: + line.product_id = product + sale_order = sale_order_form.save() + return sale_order + + +@tagged("post_install", "-at_install") +class TestSaleOrder(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass( + chart_template_ref=chart_template_ref, + ) + cls.partner = cls.env.ref("base.res_partner_1") + cls.product = cls.env.ref("product.product_product_16") + cls.sale_order = _init_sale_order(cls.env, cls.partner, cls.product) + + def _get_selection_context(self, record): + return { + "active_model": record._name, + "active_ids": record.ids, + "active_id": record.id, + } + + def test_propagate_values(self): + """Create an invoice for a sale order, + shipping values are propagated from the sale order to the invoice.""" + # Arrange + sale_order = self.sale_order + sale_order.default_transport_condition_id = self.env.ref( + "l10n_it_delivery_note_base.transport_condition_PF" + ) + sale_order.default_goods_appearance_id = self.env.ref( + "l10n_it_delivery_note_base.goods_appearance_CAR" + ) + sale_order.default_transport_reason_id = self.env.ref( + "l10n_it_delivery_note_base.transport_reason_VEN" + ) + sale_order.default_transport_method_id = self.env.ref( + "l10n_it_delivery_note_base.transport_method_MIT" + ) + sale_order.action_confirm() + + # Act + order_context = self._get_selection_context(sale_order) + payment = ( + self.env["sale.advance.payment.inv"] + .with_context(**order_context) + .create({}) + ) + payment.create_invoices() + + # Assert + invoice = sale_order.invoice_ids[0] + self.assertEqual( + invoice.delivery_transport_condition_id, + sale_order.default_transport_condition_id, + ) + self.assertEqual( + invoice.delivery_goods_appearance_id, + sale_order.default_goods_appearance_id, + ) + self.assertEqual( + invoice.delivery_transport_reason_id, + sale_order.default_transport_reason_id, + ) + self.assertEqual( + invoice.delivery_transport_method_id, + sale_order.default_transport_method_id, + ) diff --git a/l10n_it_shipping_invoice/views/account.xml b/l10n_it_shipping_invoice/views/account.xml new file mode 100644 index 000000000000..991639a4eb27 --- /dev/null +++ b/l10n_it_shipping_invoice/views/account.xml @@ -0,0 +1,87 @@ + + + + + Show shipping data in invoice form + account.move + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n_it_shipping_invoice/views/report_invoice.xml b/l10n_it_shipping_invoice/views/report_invoice.xml new file mode 100644 index 000000000000..bb48db465f36 --- /dev/null +++ b/l10n_it_shipping_invoice/views/report_invoice.xml @@ -0,0 +1,48 @@ + + + + + Shipping Invoice + account.move + qweb-pdf + l10n_it_shipping_invoice.shipping_invoice_template + l10n_it_shipping_invoice.shipping_invoice_template + (object._get_report_base_filename()) + + report + + + + + + diff --git a/setup/l10n_it_accompanying_invoice/odoo/addons/l10n_it_accompanying_invoice b/setup/l10n_it_accompanying_invoice/odoo/addons/l10n_it_accompanying_invoice deleted file mode 120000 index 293a4eadab25..000000000000 --- a/setup/l10n_it_accompanying_invoice/odoo/addons/l10n_it_accompanying_invoice +++ /dev/null @@ -1 +0,0 @@ -../../../../l10n_it_accompanying_invoice \ No newline at end of file diff --git a/setup/l10n_it_shipping_invoice/odoo/addons/l10n_it_shipping_invoice b/setup/l10n_it_shipping_invoice/odoo/addons/l10n_it_shipping_invoice new file mode 120000 index 000000000000..46c36018d09a --- /dev/null +++ b/setup/l10n_it_shipping_invoice/odoo/addons/l10n_it_shipping_invoice @@ -0,0 +1 @@ +../../../../l10n_it_shipping_invoice \ No newline at end of file diff --git a/setup/l10n_it_accompanying_invoice/setup.py b/setup/l10n_it_shipping_invoice/setup.py similarity index 100% rename from setup/l10n_it_accompanying_invoice/setup.py rename to setup/l10n_it_shipping_invoice/setup.py