diff --git a/l10n_it_delivery_note/README.rst b/l10n_it_delivery_note/README.rst index 8cba12f3d9a4..0fcb42cc3cb7 100644 --- a/l10n_it_delivery_note/README.rst +++ b/l10n_it_delivery_note/README.rst @@ -216,6 +216,10 @@ Contributors - Alessandro Uffreduzzi - Sebastiano Picchi +- `Aion Tech `__: + + - Simone Rubino + Maintainers ----------- diff --git a/l10n_it_delivery_note/__manifest__.py b/l10n_it_delivery_note/__manifest__.py index 0eb9f7125d96..f3f39389eafa 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/res_config_settings.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 eade81493a06..ad87a9af93a4 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 +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( @@ -290,6 +291,70 @@ def _domain_weight_uom(self): show_product_information = fields.Boolean(compute="_compute_boolean_flags") company_id = fields.Many2one("res.company", required=True, default=_default_company) + # 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.md b/l10n_it_delivery_note/readme/CONTRIBUTORS.md index 90c3594ef37f..11e194a617cf 100644 --- a/l10n_it_delivery_note/readme/CONTRIBUTORS.md +++ b/l10n_it_delivery_note/readme/CONTRIBUTORS.md @@ -27,3 +27,7 @@ > - Alessandro Uffreduzzi \<\> > - Sebastiano Picchi \<\> + +- [Aion Tech](https://aiontech.company/): + + - 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 f942498c8ffc..3301d1c2182c 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: - - / - -
-
+ @@ -286,117 +262,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 7c2cbd57b99e..36eb06e427d3 100644 --- a/l10n_it_delivery_note/static/description/index.html +++ b/l10n_it_delivery_note/static/description/index.html @@ -551,6 +551,11 @@

Contributors

+
  • Aion Tech:

    + +
  • diff --git a/l10n_it_shipping_invoice/README.rst b/l10n_it_shipping_invoice/README.rst new file mode 100644 index 000000000000..baa7a18df0fa --- /dev/null +++ b/l10n_it_shipping_invoice/README.rst @@ -0,0 +1,98 @@ +============================= +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/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_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 + :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 +====================== + +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 `_. + +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_shipping_invoice/__init__.py b/l10n_it_shipping_invoice/__init__.py new file mode 100644 index 000000000000..44e4267a3b6f --- /dev/null +++ b/l10n_it_shipping_invoice/__init__.py @@ -0,0 +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_shipping_invoice/__manifest__.py b/l10n_it_shipping_invoice/__manifest__.py new file mode 100644 index 000000000000..ce69d331c1c6 --- /dev/null +++ b/l10n_it_shipping_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": "16.0.1.0.0", + "category": "Accounting", + "website": "https://github.com/OCA/l10n-italy" + "/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_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_shipping_invoice/models/__init__.py b/l10n_it_shipping_invoice/models/__init__.py new file mode 100644 index 000000000000..cdfc45e0277d --- /dev/null +++ b/l10n_it_shipping_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_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_shipping_invoice/pyproject.toml b/l10n_it_shipping_invoice/pyproject.toml new file mode 100644 index 000000000000..4231d0cccb3d --- /dev/null +++ b/l10n_it_shipping_invoice/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_it_shipping_invoice/readme/CONTRIBUTORS.md b/l10n_it_shipping_invoice/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..d7c530ae5329 --- /dev/null +++ b/l10n_it_shipping_invoice/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Lorenzo Battistini \<\> +- Simone Vanin \<\> diff --git a/l10n_it_shipping_invoice/readme/DESCRIPTION.md b/l10n_it_shipping_invoice/readme/DESCRIPTION.md new file mode 100644 index 000000000000..3a25570f1c6c --- /dev/null +++ b/l10n_it_shipping_invoice/readme/DESCRIPTION.md @@ -0,0 +1,9 @@ +**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_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_shipping_invoice/readme/USAGE.md b/l10n_it_shipping_invoice/readme/USAGE.md new file mode 100644 index 000000000000..39834696eb61 --- /dev/null +++ b/l10n_it_shipping_invoice/readme/USAGE.md @@ -0,0 +1,4 @@ +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_shipping_invoice/static/description/icon.png b/l10n_it_shipping_invoice/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_shipping_invoice/static/description/icon.png differ diff --git a/l10n_it_shipping_invoice/static/description/index.html b/l10n_it_shipping_invoice/static/description/index.html new file mode 100644 index 000000000000..b1934a9f711e --- /dev/null +++ b/l10n_it_shipping_invoice/static/description/index.html @@ -0,0 +1,438 @@ + + + + + +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

    +

    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.

    +

    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_shipping_invoice/tests/__init__.py b/l10n_it_shipping_invoice/tests/__init__.py new file mode 100644 index 000000000000..37126205f1b9 --- /dev/null +++ b/l10n_it_shipping_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_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_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_shipping_invoice/setup.py b/setup/l10n_it_shipping_invoice/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/l10n_it_shipping_invoice/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)