diff --git a/l10n_it_accompanying_invoice/README.rst b/l10n_it_accompanying_invoice/README.rst new file mode 100644 index 000000000000..873afd1cecac --- /dev/null +++ b/l10n_it_accompanying_invoice/README.rst @@ -0,0 +1,103 @@ +============================= +ITA - Fattura accompagnatoria +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:47e2b4ae93928006b62502df808ccab3b5f961ed66ec2be01da41807a4c16011 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/12.0/l10n_it_accompanying_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-12-0/l10n-italy-12-0-l10n_it_accompanying_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=12.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Questo modulo consente di stampare una fattura accompagnatoria, per visualizzare i dati di *Informazioni di spedizione* nella fattura. + +**English** + +This module allows you to print an accompanying invoice, to view *Shipping Information* data inside the invoice. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +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 +=========== + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Agile Business Group + +Contributors +~~~~~~~~~~~~ + +* Lorenzo Battistini +* Simone Vanin + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +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_accompanying_invoice/__init__.py new file mode 100644 index 000000000000..c70416271455 --- /dev/null +++ b/l10n_it_accompanying_invoice/__init__.py @@ -0,0 +1,5 @@ +# 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 new file mode 100644 index 000000000000..c17bfbdfba50 --- /dev/null +++ b/l10n_it_accompanying_invoice/__manifest__.py @@ -0,0 +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": "14.0.1.0.0", + "category": "Accounting", + "website": "https://github.com/OCA/l10n-italy" + "/tree/14.0/l10n_it_accompanying_invoice", + "author": "Agile Business Group, " "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "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 new file mode 100644 index 000000000000..f8ad8ed27bfa --- /dev/null +++ b/l10n_it_accompanying_invoice/i18n/it.po @@ -0,0 +1,199 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_accompanying_invoice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-19 14:29+0000\n" +"PO-Revision-Date: 2024-11-19 14:29+0000\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,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:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_account_move__display_name +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_sale_order__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. 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__id +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_sale_order__id +msgid "ID" +msgstr "" + +#. 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____last_update +#: model:ir.model.fields,field_description:l10n_it_accompanying_invoice.field_sale_order____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. 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_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_move__delivery_transport_datetime +msgid "Transport Date of Delivery" +msgstr "Data di trasporto della consegna" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Transport Method" +msgstr "Metodo di trasporto" + +#. 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" + +#. module: l10n_it_accompanying_invoice +#: model_terms:ir.ui.view,arch_db:l10n_it_accompanying_invoice.view_move_form +msgid "Volume" +msgstr "" + +#. 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/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 new file mode 100644 index 000000000000..cdfc45e0277d --- /dev/null +++ b/l10n_it_accompanying_invoice/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import account_move +from . import sale_order 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/CONTRIBUTORS.rst b/l10n_it_accompanying_invoice/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..6938187b127a --- /dev/null +++ b/l10n_it_accompanying_invoice/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Lorenzo Battistini +* Simone Vanin diff --git a/l10n_it_accompanying_invoice/readme/DESCRIPTION.rst b/l10n_it_accompanying_invoice/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..3b80d0dde44f --- /dev/null +++ b/l10n_it_accompanying_invoice/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +**Italiano** + +Questo modulo consente di stampare una fattura accompagnatoria, per visualizzare i dati di *Informazioni di spedizione* nella fattura. + +**English** + +This module allows you to print an accompanying invoice, to view *Shipping Information* data inside the invoice. 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/readme/USAGE.rst b/l10n_it_accompanying_invoice/readme/USAGE.rst new file mode 100644 index 000000000000..c1c1d28e3cd6 --- /dev/null +++ b/l10n_it_accompanying_invoice/readme/USAGE.rst @@ -0,0 +1,3 @@ +Valorizzare i campi del foglio *Informazioni di spedizione*. + +Usare l'azione *Fattura accompagnatoria* all'interno della lista di azioni *Stampa*, nella vista delle fatture. diff --git a/l10n_it_accompanying_invoice/static/description/icon.png b/l10n_it_accompanying_invoice/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_accompanying_invoice/static/description/icon.png differ diff --git a/l10n_it_accompanying_invoice/static/description/index.html b/l10n_it_accompanying_invoice/static/description/index.html new file mode 100644 index 000000000000..17036081f077 --- /dev/null +++ b/l10n_it_accompanying_invoice/static/description/index.html @@ -0,0 +1,444 @@ + + + + + + +ITA - Fattura accompagnatoria + + + +
+

ITA - Fattura accompagnatoria

+ + +

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.

+

English

+

This module allows you to print an accompanying invoice, to view Shipping Information data inside the invoice.

+

Table of contents

+ +
+

Usage

+

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

+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Agile Business Group
  • +
+
+
+

Contributors

+ +
+
+

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.

+

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_accompanying_invoice/tests/__init__.py new file mode 100644 index 000000000000..37126205f1b9 --- /dev/null +++ b/l10n_it_accompanying_invoice/tests/__init__.py @@ -0,0 +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 new file mode 100644 index 000000000000..6ee539bac228 --- /dev/null +++ b/l10n_it_accompanying_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", + ) + + report = self.env["ir.actions.report"]._get_report_from_name( + "l10n_it_accompanying_invoice.shipping_invoice_template" + ) + html = report._render_qweb_html(invoice.id) + self.assertTrue(html) 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 new file mode 100644 index 000000000000..991639a4eb27 --- /dev/null +++ b/l10n_it_accompanying_invoice/views/account.xml @@ -0,0 +1,87 @@ + + + + + Show shipping data in invoice form + account.move + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n_it_accompanying_invoice/views/report_invoice.xml b/l10n_it_accompanying_invoice/views/report_invoice.xml new file mode 100644 index 000000000000..9b5195929961 --- /dev/null +++ b/l10n_it_accompanying_invoice/views/report_invoice.xml @@ -0,0 +1,48 @@ + + + + + Shipping Invoice + account.move + qweb-pdf + l10n_it_accompanying_invoice.shipping_invoice_template + l10n_it_accompanying_invoice.shipping_invoice_template + (object._get_report_base_filename()) + + report + + + + + + diff --git a/l10n_it_delivery_note/README.rst b/l10n_it_delivery_note/README.rst index 1ccea5df8049..ca6a533bfed1 100644 --- a/l10n_it_delivery_note/README.rst +++ b/l10n_it_delivery_note/README.rst @@ -209,6 +209,8 @@ Contributors * Alessandro Uffreduzzi * Sebastiano Picchi * Sergio Corato +* `Aion Tech `_: + * Simone Rubino Maintainers ~~~~~~~~~~~ diff --git a/l10n_it_delivery_note/__manifest__.py b/l10n_it_delivery_note/__manifest__.py index d5736b95a2a9..6a107d49e845 100644 --- a/l10n_it_delivery_note/__manifest__.py +++ b/l10n_it_delivery_note/__manifest__.py @@ -31,6 +31,7 @@ "security/ir_rule.xml", "security/res_groups.xml", "security/res_users.xml", + "report/delivery_data.xml", "report/report_delivery_note.xml", "views/account_move.xml", "views/assets.xml", diff --git a/l10n_it_delivery_note/mixins/__init__.py b/l10n_it_delivery_note/mixins/__init__.py index 5fb6adab4175..28ad667b944c 100644 --- a/l10n_it_delivery_note/mixins/__init__.py +++ b/l10n_it_delivery_note/mixins/__init__.py @@ -1,2 +1,3 @@ +from . import delivery_mixin from . import picking_checker from . import shipping_updater diff --git a/l10n_it_delivery_note/mixins/delivery_mixin.py b/l10n_it_delivery_note/mixins/delivery_mixin.py new file mode 100644 index 000000000000..b1ec55f39eb5 --- /dev/null +++ b/l10n_it_delivery_note/mixins/delivery_mixin.py @@ -0,0 +1,91 @@ +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +def _default_volume_uom(model): + return model.env.ref("uom.product_uom_litre", raise_if_not_found=False) + + +def _domain_volume_uom(model): + uom_category_id = model.env.ref( + "uom.product_uom_categ_vol", raise_if_not_found=False + ) + + return [("category_id", "=", uom_category_id.id)] + + +def _default_weight_uom(model): + return model.env.ref("uom.product_uom_kgm", raise_if_not_found=False) + + +def _domain_weight_uom(model): + uom_category_id = model.env.ref( + "uom.product_uom_categ_kgm", raise_if_not_found=False + ) + + return [("category_id", "=", uom_category_id.id)] + + +class DeliveryData(models.AbstractModel): + _name = "l10n_it_delivery_note.delivery_mixin" + _description = "Common data for records to be delivered" + + delivery_transport_reason_id = fields.Many2one( + comodel_name="stock.picking.transport.reason", + string="Reason of transport of Delivery", + ) + delivery_transport_condition_id = fields.Many2one( + comodel_name="stock.picking.transport.condition", + string="Condition of transport of Delivery", + ) + delivery_transport_method_id = fields.Many2one( + comodel_name="stock.picking.transport.method", + string="Method of transport of Delivery", + ) + delivery_carrier_id = fields.Many2one( + comodel_name="res.partner", + string="Carrier of Delivery", + ) + delivery_goods_appearance_id = fields.Many2one( + comodel_name="stock.picking.goods.appearance", + string="Appearance of goods of Delivery", + ) + delivery_volume_uom_id = fields.Many2one( + "uom.uom", + string="Volume of Delivery UoM", + default=_default_volume_uom, + domain=_domain_volume_uom, + ) + delivery_volume = fields.Float( + string="Volume of Delivery", + ) + delivery_gross_weight_uom_id = fields.Many2one( + "uom.uom", + string="Gross Weight of Delivery UoM", + default=_default_weight_uom, + domain=_domain_weight_uom, + ) + delivery_gross_weight = fields.Float( + string="Gross Weight of Delivery", + ) + delivery_net_weight_uom_id = fields.Many2one( + "uom.uom", + string="Net Weight of Delivery UoM", + default=_default_weight_uom, + domain=_domain_weight_uom, + ) + delivery_net_weight = fields.Float( + string="Net Weight of Delivery", + ) + delivery_transport_datetime = fields.Datetime( + string="Transport Date of Delivery", + ) + delivery_packages = fields.Integer( + string="Packages of Delivery", + ) + delivery_note = fields.Html( + string="Internal note of delivery", + ) diff --git a/l10n_it_delivery_note/models/stock_delivery_note.py b/l10n_it_delivery_note/models/stock_delivery_note.py index ec95237d3ab3..0a76a0bd49e0 100644 --- a/l10n_it_delivery_note/models/stock_delivery_note.py +++ b/l10n_it_delivery_note/models/stock_delivery_note.py @@ -1,11 +1,19 @@ # Copyright (c) 2019, Link IT Europe Srl # @author: Matteo Bilotta +# Copyright 2023 Simone Rubino - Aion Tech +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import datetime from odoo import _, api, fields, models from odoo.exceptions import UserError, ValidationError +from ..mixins.delivery_mixin import ( + _default_volume_uom, + _default_weight_uom, + _domain_volume_uom, + _domain_weight_uom, +) from ..mixins.picking_checker import ( DOMAIN_PICKING_TYPES, DONE_PICKING_STATE, @@ -46,6 +54,7 @@ class StockDeliveryNote(models.Model): "mail.activity.mixin", "stock.picking.checker.mixin", "shipping.information.updater.mixin", + "l10n_it_delivery_note.delivery_mixin", ] _description = "Delivery Note" _order = "date DESC, id DESC" @@ -64,24 +73,16 @@ def _default_type(self): ) def _default_volume_uom(self): - return self.env.ref("uom.product_uom_litre", raise_if_not_found=False) + return _default_volume_uom(self) def _domain_volume_uom(self): - uom_category_id = self.env.ref( - "uom.product_uom_categ_vol", raise_if_not_found=False - ) - - return [("category_id", "=", uom_category_id.id)] + return _domain_volume_uom(self) def _default_weight_uom(self): - return self.env.ref("uom.product_uom_kgm", raise_if_not_found=False) + return _default_weight_uom(self) def _domain_weight_uom(self): - uom_category_id = self.env.ref( - "uom.product_uom_categ_kgm", raise_if_not_found=False - ) - - return [("category_id", "=", uom_category_id.id)] + return _domain_weight_uom(self) active = fields.Boolean(default=True) name = fields.Char( @@ -309,6 +310,70 @@ def _domain_weight_uom(self): company_id = fields.Many2one("res.company", required=True, default=_default_company) show_discount = fields.Boolean(compute="_compute_show_discount") + # Sync with delivery mixin fields + delivery_transport_reason_id = fields.Many2one( + related="transport_reason_id", + readonly=True, + ) + delivery_transport_condition_id = fields.Many2one( + related="transport_condition_id", + readonly=True, + ) + delivery_transport_method_id = fields.Many2one( + related="transport_method_id", + readonly=True, + ) + delivery_carrier_id = fields.Many2one( + related="carrier_id", + readonly=True, + ) + delivery_goods_appearance_id = fields.Many2one( + related="goods_appearance_id", + readonly=True, + ) + delivery_volume_uom_id = fields.Many2one( + related="volume_uom_id", + readonly=True, + default=None, + domain=None, + ) + delivery_volume = fields.Float( + related="volume", + readonly=True, + ) + delivery_gross_weight_uom_id = fields.Many2one( + related="gross_weight_uom_id", + readonly=True, + default=None, + domain=None, + ) + delivery_gross_weight = fields.Float( + related="gross_weight", + readonly=True, + ) + delivery_net_weight_uom_id = fields.Many2one( + related="net_weight_uom_id", + readonly=True, + default=None, + domain=None, + ) + delivery_net_weight = fields.Float( + related="net_weight", + readonly=True, + ) + delivery_transport_datetime = fields.Datetime( + related="transport_datetime", + readonly=True, + ) + delivery_packages = fields.Integer( + related="packages", + readonly=True, + ) + delivery_note = fields.Html( + related="note", + readonly=True, + ) + _sql_constraints = [ ( "name_uniq", diff --git a/l10n_it_delivery_note/readme/CONTRIBUTORS.rst b/l10n_it_delivery_note/readme/CONTRIBUTORS.rst index 375f4b367a22..cfc792e93fee 100644 --- a/l10n_it_delivery_note/readme/CONTRIBUTORS.rst +++ b/l10n_it_delivery_note/readme/CONTRIBUTORS.rst @@ -15,3 +15,5 @@ * Alessandro Uffreduzzi * Sebastiano Picchi * Sergio Corato +* `Aion Tech `_: + * Simone Rubino diff --git a/l10n_it_delivery_note/report/delivery_data.xml b/l10n_it_delivery_note/report/delivery_data.xml new file mode 100644 index 000000000000..4460bd254edb --- /dev/null +++ b/l10n_it_delivery_note/report/delivery_data.xml @@ -0,0 +1,136 @@ + + + + + + + diff --git a/l10n_it_delivery_note/report/report_delivery_note.xml b/l10n_it_delivery_note/report/report_delivery_note.xml index 998d71f1e8ba..446bbb7d7856 100644 --- a/l10n_it_delivery_note/report/report_delivery_note.xml +++ b/l10n_it_delivery_note/report/report_delivery_note.xml @@ -2,6 +2,7 @@ @@ -121,32 +122,7 @@ -
-
- Reason of Transport: -

-

-
- Carriage Condition: -

-

-
- Method of Transport: -

-

-
- Method of Transport / Carrier: - - / - -
-
+ @@ -367,117 +343,7 @@ -
- - - - - - - - - - - - - -
-
Goods Description
-
-
-
Gross Weight
-
-
-
Net Weight
-
-
-
Transport date
-
-
-
Packages
-
-
-
Notes
-
-
-
- - - - - - -
-
Carrier's Signature
-
-
-
-
Driver's Signature
-
-
-
-
Recipient's Signature
-
-
-
-
+
diff --git a/l10n_it_delivery_note/static/description/index.html b/l10n_it_delivery_note/static/description/index.html index 5b2c1111140f..0e82beaeb5c0 100644 --- a/l10n_it_delivery_note/static/description/index.html +++ b/l10n_it_delivery_note/static/description/index.html @@ -545,6 +545,14 @@

Contributors

  • Sergio Corato <https://github.com/sergiocorato>
  • +
  • +
    Aion Tech:
    +
    +
    +
    +
  • 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 new file mode 120000 index 000000000000..293a4eadab25 --- /dev/null +++ b/setup/l10n_it_accompanying_invoice/odoo/addons/l10n_it_accompanying_invoice @@ -0,0 +1 @@ +../../../../l10n_it_accompanying_invoice \ No newline at end of file diff --git a/setup/l10n_it_accompanying_invoice/setup.py b/setup/l10n_it_accompanying_invoice/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_accompanying_invoice/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)