diff --git a/l10n_it_accompanying_invoice/README.rst b/l10n_it_accompanying_invoice/README.rst index 9dbc18a1d82e..873afd1cecac 100644 --- a/l10n_it_accompanying_invoice/README.rst +++ b/l10n_it_accompanying_invoice/README.rst @@ -48,6 +48,19 @@ 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** + +Il modulo è stato migrato, ma gli script di migrazione non sono stati +provati e quindi sono stati commentati. Si possono provare in un +ambiente di test decommentando + +- il riferimento a ``hooks.py`` in ``__init__.py`` +- ``external_dependencies`` e ``pre_init_hook`` in ``__manifest__.py`` +- le righe di codice in ``migrations/16.0.1.0.0/pre-migrate.py`` + Bug Tracker =========== diff --git a/l10n_it_accompanying_invoice/__init__.py b/l10n_it_accompanying_invoice/__init__.py index 31660d6a9650..252cb47ba60b 100644 --- a/l10n_it_accompanying_invoice/__init__.py +++ b/l10n_it_accompanying_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_accompanying_invoice/__manifest__.py index 6c0d2026caa9..b4cff3c935b9 100644 --- a/l10n_it_accompanying_invoice/__manifest__.py +++ b/l10n_it_accompanying_invoice/__manifest__.py @@ -1,24 +1,31 @@ # 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_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", } diff --git a/l10n_it_accompanying_invoice/hooks.py b/l10n_it_accompanying_invoice/hooks.py new file mode 100644 index 000000000000..3b8399ec1dc8 --- /dev/null +++ b/l10n_it_accompanying_invoice/hooks.py @@ -0,0 +1,219 @@ +# 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 + +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"): + migrate_old_module(cr) diff --git a/l10n_it_accompanying_invoice/i18n/it.po b/l10n_it_accompanying_invoice/i18n/it.po index dac33aa85015..aa758cd3b2c6 100644 --- a/l10n_it_accompanying_invoice/i18n/it.po +++ b/l10n_it_accompanying_invoice/i18n/it.po @@ -4,43 +4,178 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 16.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" +"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" -"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" +#: model:ir.actions.report,print_report_name:l10n_it_accompanying_invoice.shipping_invoice_report +msgid "(object._get_report_base_filename())" +msgstr "" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_goods_appearance_id +msgid "Appearance of goods of Delivery" +msgstr "Aspetto dei beni della consegna" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Carrier" +msgstr "Vettore" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_carrier_id +msgid "Carrier of Delivery" +msgstr "Vettore della consegna" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_transport_condition_id +msgid "Condition of transport of Delivery" +msgstr "Condizione di trasporto della consegna" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Goods Appearance" +msgstr "Aspetto dei beni" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Gross Weight" +msgstr "Peso lordo" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_gross_weight +msgid "Gross Weight of Delivery" +msgstr "Peso lordo della consegna" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_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_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_note +msgid "Internal note of delivery" +msgstr "Note interne della consegna" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model,name:l10n_it_accompanying_invoice.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_transport_method_id +msgid "Method of transport of Delivery" +msgstr "Metodo di trasporto della consegna" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Net Weight" +msgstr "Peso netto" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_net_weight +msgid "Net Weight of Delivery" +msgstr "Peso netto della consegna" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_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_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Note" +msgstr "" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Other" +msgstr "Altro" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Packages" +msgstr "Pacchi" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_packages +msgid "Packages of Delivery" +msgstr "Pacchi della consegna" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Parcels" +msgstr "Colli" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_transport_reason_id +msgid "Reason of transport of Delivery" +msgstr "Causale di trasporto della consegna" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model,name:l10n_it_accompanying_invoice.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Shipping Information" +msgstr "Informazioni di spedizione" + +#. module: l10n_it_accompanying_invoice +#: model:ir.actions.report,name:l10n_it_accompanying_invoice.shipping_invoice_report +msgid "Shipping Invoice" msgstr "Fattura accompagnatoria" #. module: l10n_it_accompanying_invoice -#: model:ir.model,name:l10n_it_accompanying_invoice.model_account_invoice -msgid "Invoice" -msgstr "Fattura" +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Transport" +msgstr "Trasporto" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Transport Condition" +msgstr "Condizione di trasporto" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Transport Date" +msgstr "Data di trasporto" #. module: l10n_it_accompanying_invoice -#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_invoice__note -msgid "Notes" -msgstr "Note" +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_transport_datetime +msgid "Transport Date of Delivery" +msgstr "Data di trasporto della consegna" #. 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" +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Transport Method" +msgstr "Metodo di trasporto" -#~ msgid "Gross Weight UoM" -#~ msgstr "UdM peso lordo" +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Transport Reason" +msgstr "Causale di trasporto" -#~ msgid "Net Weight UoM" -#~ msgstr "UdM peso netto" +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Volume" +msgstr "" -#~ msgid "Volume UoM" -#~ msgstr "UdM volume" +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_volume +msgid "Volume of Delivery" +msgstr "Volume della consegna" + +#. module: l10n_it_accompanying_invoice +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__delivery_volume_uom_id +msgid "Volume of Delivery UoM" +msgstr "UdM del volume della consegna" 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/migrations/16.0.1.0.0/pre-migrate.py b/l10n_it_accompanying_invoice/migrations/16.0.1.0.0/pre-migrate.py new file mode 100644 index 000000000000..f9a68b7ae790 --- /dev/null +++ b/l10n_it_accompanying_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_accompanying_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_accompanying_invoice/models/__init__.py index 3a3cf6bb90b0..cdfc45e0277d 100644 --- a/l10n_it_accompanying_invoice/models/__init__.py +++ b/l10n_it_accompanying_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_accompanying_invoice/models/account_invoice.py b/l10n_it_accompanying_invoice/models/account_invoice.py deleted file mode 100644 index 0437fbb3cc3c..000000000000 --- a/l10n_it_accompanying_invoice/models/account_invoice.py +++ /dev/null @@ -1,14 +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/models/account_move.py b/l10n_it_accompanying_invoice/models/account_move.py new file mode 100644 index 000000000000..ff71322c00fb --- /dev/null +++ b/l10n_it_accompanying_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_accompanying_invoice/models/sale_order.py b/l10n_it_accompanying_invoice/models/sale_order.py new file mode 100644 index 000000000000..1f5e633a78bd --- /dev/null +++ b/l10n_it_accompanying_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/readme/ROADMAP.md b/l10n_it_accompanying_invoice/readme/ROADMAP.md new file mode 100644 index 000000000000..28c5839a2564 --- /dev/null +++ b/l10n_it_accompanying_invoice/readme/ROADMAP.md @@ -0,0 +1,9 @@ +**Italiano** + +Il modulo è stato migrato, ma gli script di migrazione non +sono stati provati e quindi sono stati commentati. +Si possono provare in un ambiente di test decommentando +- il riferimento a `hooks.py` in `__init__.py` +- `external_dependencies` e `pre_init_hook` in `__manifest__.py` +- le righe di codice in `migrations/16.0.1.0.0/pre-migrate.py` + diff --git a/l10n_it_accompanying_invoice/static/description/index.html b/l10n_it_accompanying_invoice/static/description/index.html index 5566fd655d2a..17036081f077 100644 --- a/l10n_it_accompanying_invoice/static/description/index.html +++ b/l10n_it_accompanying_invoice/static/description/index.html @@ -378,11 +378,12 @@

ITA - Fattura accompagnatoria

+
+

Known issues / Roadmap

+

Italiano

+

Il modulo è stato migrato, ma gli script di migrazione non sono stati +provati e quindi sono stati commentati. Si possono provare in un +ambiente di test decommentando

+ +
-

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 @@ -401,22 +414,22 @@

Bug Tracker

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 diff --git a/l10n_it_accompanying_invoice/tests/__init__.py b/l10n_it_accompanying_invoice/tests/__init__.py index 02415651fe44..37126205f1b9 100644 --- a/l10n_it_accompanying_invoice/tests/__init__.py +++ b/l10n_it_accompanying_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_accompanying_invoice/tests/test_account_move.py b/l10n_it_accompanying_invoice/tests/test_account_move.py new file mode 100644 index 000000000000..125c8df2e953 --- /dev/null +++ b/l10n_it_accompanying_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_accompanying_invoice/tests/test_report.py b/l10n_it_accompanying_invoice/tests/test_report.py index c0c1fd0ffb69..e8dad3c30cf6 100644 --- a/l10n_it_accompanying_invoice/tests/test_report.py +++ b/l10n_it_accompanying_invoice/tests/test_report.py @@ -1,19 +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). -import odoo.tests +from odoo.tests import tagged -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' - ) +from odoo.addons.account.tests.common import AccountTestInvoicingCommon - 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]) +@tagged("post_install", "-at_install") +class TestReport(AccountTestInvoicingCommon): + def test_report(self): + invoice = self.init_invoice( + "out_invoice", + ) - self.assertTrue(html) + html = self.env["ir.actions.report"]._render_qweb_html( + "l10n_it_accompanying_invoice.shipping_invoice_template", + [invoice.id], + ) + self.assertTrue(html) \ No newline at end of file diff --git a/l10n_it_accompanying_invoice/tests/test_sale_order.py b/l10n_it_accompanying_invoice/tests/test_sale_order.py new file mode 100644 index 000000000000..5e95115e07cd --- /dev/null +++ b/l10n_it_accompanying_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_accompanying_invoice/views/account.xml b/l10n_it_accompanying_invoice/views/account.xml index ace59b812a67..62fefa40ccc0 100644 --- a/l10n_it_accompanying_invoice/views/account.xml +++ b/l10n_it_accompanying_invoice/views/account.xml @@ -1,15 +1,87 @@ - + - - - account.invoice.form.ddt.uom - account.invoice - - - - - - - - + + + Show shipping data in invoice form + account.move + + + + + + + + + + + + + + +

+ + +
+