diff --git a/intrastat_delivery/README.rst b/intrastat_delivery/README.rst new file mode 100644 index 0000000..dc58a4e --- /dev/null +++ b/intrastat_delivery/README.rst @@ -0,0 +1,91 @@ +================================================ +Propagate incoterm from sale delivery to invoice +================================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8d15cc57390a3af06ebc7dff9c2a29b07535e778c24999e8eb5b082b5a58e670 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fintrastat--extrastat-lightgray.png?logo=github + :target: https://github.com/OCA/intrastat-extrastat/tree/16.0/intrastat_delivery + :alt: OCA/intrastat-extrastat +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/intrastat-extrastat-16-0/intrastat-extrastat-16-0-intrastat_delivery + :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/intrastat-extrastat&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon allows you to define an "Incoterm" and an "Intrastat Transport Mode" at the +"Shipping Methods" of sales. When these values are established, they will be the ones +that prevail in the sales orders, if they are not defined, the default values that were +established in "Settings" will apply. + +The mode of transport and incoterm are assigned to the sales order when it goes from +"Quotation" to "Order". Additionally, the values will be dragged to the invoices created +from that sales order. + +It is recommended to set TRUE the "Show incoterms in orders and invoices" value at +"Settings / Sales". + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Este módulo no requiere de ninguna consideración especial para su uso. + +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 +~~~~~~~ + +* FactorLibre + +Contributors +~~~~~~~~~~~~ + +* Aritz Olea + +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/intrastat-extrastat `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/intrastat_delivery/__init__.py b/intrastat_delivery/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/intrastat_delivery/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/intrastat_delivery/__manifest__.py b/intrastat_delivery/__manifest__.py new file mode 100644 index 0000000..409b127 --- /dev/null +++ b/intrastat_delivery/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": "Propagate incoterm from sale delivery to invoice", + "version": "16.0.1.0.0", + "category": "Accounting", + "author": "FactorLibre, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/intrastat-extrastat", + "license": "AGPL-3", + "summary": "Propagates the value of the incoterm fields from the order shipping " + "method to the invoices", + "depends": [ + "sale_stock", + "delivery", + "intrastat_product", + ], + "data": ["views/delivery_carrier_view.xml"], + "installable": True, + "application": False, +} diff --git a/intrastat_delivery/i18n/es.po b/intrastat_delivery/i18n/es.po new file mode 100644 index 0000000..908f7f3 --- /dev/null +++ b/intrastat_delivery/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * intrastat_delivery +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-12-26 08:14+0000\n" +"PO-Revision-Date: 2023-12-26 09:15+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"X-Generator: Poedit 3.0.1\n" + +#. module: intrastat_delivery +#: model:ir.model.fields,field_description:intrastat_delivery.field_delivery_carrier__incoterm +msgid "Incoterm" +msgstr "" + +#. module: intrastat_delivery +#: model:ir.model.fields,help:intrastat_delivery.field_delivery_carrier__incoterm +msgid "" +"International Commercial Terms are a series of predefined commercial terms " +"used in international transactions." +msgstr "" +"Los términos de comercio internacional son una serie de condiciones " +"comerciales usadas en las transacciones internacionales." + +#. module: intrastat_delivery +#: model:ir.model.fields,field_description:intrastat_delivery.field_delivery_carrier__intrastat_transport_id +msgid "Intrastat Transport Mode" +msgstr "Modo de transporte Intrastat" + +#. module: intrastat_delivery +#: model:ir.model,name:intrastat_delivery.model_sale_order +msgid "Sales Order" +msgstr "Pedido de venta" + +#. module: intrastat_delivery +#: model:ir.model,name:intrastat_delivery.model_delivery_carrier +msgid "Shipping Methods" +msgstr "Métodos de envío" diff --git a/intrastat_delivery/i18n/intrastat_delivery.pot b/intrastat_delivery/i18n/intrastat_delivery.pot new file mode 100644 index 0000000..c35c1f2 --- /dev/null +++ b/intrastat_delivery/i18n/intrastat_delivery.pot @@ -0,0 +1,43 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * intrastat_delivery +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-12-26 08:14+0000\n" +"PO-Revision-Date: 2023-12-26 08:14+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: intrastat_delivery +#: model:ir.model.fields,field_description:intrastat_delivery.field_delivery_carrier__incoterm +msgid "Incoterm" +msgstr "" + +#. module: intrastat_delivery +#: model:ir.model.fields,help:intrastat_delivery.field_delivery_carrier__incoterm +msgid "" +"International Commercial Terms are a series of predefined commercial terms " +"used in international transactions." +msgstr "" + +#. module: intrastat_delivery +#: model:ir.model.fields,field_description:intrastat_delivery.field_delivery_carrier__intrastat_transport_id +msgid "Intrastat Transport Mode" +msgstr "" + +#. module: intrastat_delivery +#: model:ir.model,name:intrastat_delivery.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: intrastat_delivery +#: model:ir.model,name:intrastat_delivery.model_delivery_carrier +msgid "Shipping Methods" +msgstr "" diff --git a/intrastat_delivery/models/__init__.py b/intrastat_delivery/models/__init__.py new file mode 100644 index 0000000..212a1ca --- /dev/null +++ b/intrastat_delivery/models/__init__.py @@ -0,0 +1,3 @@ +# © 2023 FactorLibre - Aritz Olea +from . import delivery_carrier +from . import sale_order diff --git a/intrastat_delivery/models/delivery_carrier.py b/intrastat_delivery/models/delivery_carrier.py new file mode 100644 index 0000000..538717f --- /dev/null +++ b/intrastat_delivery/models/delivery_carrier.py @@ -0,0 +1,16 @@ +# © 2023 FactorLibre - Aritz Olea +from odoo import fields, models + + +class DeliveryCarrier(models.Model): + _inherit = "delivery.carrier" + + incoterm = fields.Many2one( + comodel_name="account.incoterms", + help="International Commercial Terms are a series of predefined " + "commercial terms used in international transactions.", + ) + intrastat_transport_id = fields.Many2one( + comodel_name="intrastat.transport_mode", + string="Intrastat Transport Mode", + ) diff --git a/intrastat_delivery/models/sale_order.py b/intrastat_delivery/models/sale_order.py new file mode 100644 index 0000000..8818b3c --- /dev/null +++ b/intrastat_delivery/models/sale_order.py @@ -0,0 +1,27 @@ +# © 2023 FactorLibre - Aritz Olea +from odoo import models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + def _action_confirm(self): + ret = super()._action_confirm() + for order in self: + order.write( + { + "incoterm": order.carrier_id.incoterm.id, + "intrastat_transport_id": order.carrier_id.intrastat_transport_id.id, + } + ) + return ret + + def _prepare_invoice(self): + ret = super()._prepare_invoice() + ret.update( + { + "invoice_incoterm_id": self.incoterm.id, + "intrastat_transport_id": self.intrastat_transport_id.id, + } + ) + return ret diff --git a/intrastat_delivery/readme/CONFIGURE.rst b/intrastat_delivery/readme/CONFIGURE.rst new file mode 100644 index 0000000..e69de29 diff --git a/intrastat_delivery/readme/CONTRIBUTORS.rst b/intrastat_delivery/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..fdc2148 --- /dev/null +++ b/intrastat_delivery/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Aritz Olea diff --git a/intrastat_delivery/readme/CREDITS.rst b/intrastat_delivery/readme/CREDITS.rst new file mode 100644 index 0000000..e69de29 diff --git a/intrastat_delivery/readme/DESCRIPTION.rst b/intrastat_delivery/readme/DESCRIPTION.rst new file mode 100644 index 0000000..c5cae50 --- /dev/null +++ b/intrastat_delivery/readme/DESCRIPTION.rst @@ -0,0 +1,11 @@ +This addon allows you to define an "Incoterm" and an "Intrastat Transport Mode" at the +"Shipping Methods" of sales. When these values are established, they will be the ones +that prevail in the sales orders, if they are not defined, the default values that were +established in "Settings" will apply. + +The mode of transport and incoterm are assigned to the sales order when it goes from +"Quotation" to "Order". Additionally, the values will be dragged to the invoices created +from that sales order. + +It is recommended to set TRUE the "Show incoterms in orders and invoices" value at +"Settings / Sales". \ No newline at end of file diff --git a/intrastat_delivery/readme/DEVELOP.rst b/intrastat_delivery/readme/DEVELOP.rst new file mode 100644 index 0000000..e69de29 diff --git a/intrastat_delivery/readme/HISTORY.rst b/intrastat_delivery/readme/HISTORY.rst new file mode 100644 index 0000000..e69de29 diff --git a/intrastat_delivery/readme/INSTALL.rst b/intrastat_delivery/readme/INSTALL.rst new file mode 100644 index 0000000..e69de29 diff --git a/intrastat_delivery/readme/ROADMAP.rst b/intrastat_delivery/readme/ROADMAP.rst new file mode 100644 index 0000000..e69de29 diff --git a/intrastat_delivery/readme/USAGE.rst b/intrastat_delivery/readme/USAGE.rst new file mode 100644 index 0000000..1c3c705 --- /dev/null +++ b/intrastat_delivery/readme/USAGE.rst @@ -0,0 +1 @@ +Este módulo no requiere de ninguna consideración especial para su uso. diff --git a/intrastat_delivery/static/description/icon.png b/intrastat_delivery/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/intrastat_delivery/static/description/icon.png differ diff --git a/intrastat_delivery/static/description/index.html b/intrastat_delivery/static/description/index.html new file mode 100644 index 0000000..d62941d --- /dev/null +++ b/intrastat_delivery/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Propagate incoterm from sale delivery to invoice + + + +
+

Propagate incoterm from sale delivery to invoice

+ + +

Beta License: AGPL-3 OCA/intrastat-extrastat Translate me on Weblate Try me on Runboat

+

This addon allows you to define an “Incoterm” and an “Intrastat Transport Mode” at the +“Shipping Methods” of sales. When these values are established, they will be the ones +that prevail in the sales orders, if they are not defined, the default values that were +established in “Settings” will apply.

+

The mode of transport and incoterm are assigned to the sales order when it goes from +“Quotation” to “Order”. Additionally, the values will be dragged to the invoices created +from that sales order.

+

It is recommended to set TRUE the “Show incoterms in orders and invoices” value at +“Settings / Sales”.

+

Table of contents

+ +
+

Usage

+

Este módulo no requiere de ninguna consideración especial para su uso.

+
+
+

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

+
    +
  • FactorLibre
  • +
+
+ +
+

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/intrastat-extrastat project on GitHub.

+

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

+
+
+
+ + diff --git a/intrastat_delivery/tests/__init__.py b/intrastat_delivery/tests/__init__.py new file mode 100644 index 0000000..cec1484 --- /dev/null +++ b/intrastat_delivery/tests/__init__.py @@ -0,0 +1 @@ +from . import test_intrastat_delivery diff --git a/intrastat_delivery/tests/test_intrastat_delivery.py b/intrastat_delivery/tests/test_intrastat_delivery.py new file mode 100644 index 0000000..e985788 --- /dev/null +++ b/intrastat_delivery/tests/test_intrastat_delivery.py @@ -0,0 +1,89 @@ +# © 2023 FactorLibre - Aritz Olea +from odoo import Command +from odoo.tests import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestIntrastatDelivery(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_1 = cls.env["product.product"].create( + {"name": "Service", "type": "consu", "invoice_policy": "order"} + ) + cls.product_delivery_1 = cls.env["product.product"].create( + { + "name": "Delivery Product 1", + "type": "service", + "list_price": 10.0, + "categ_id": cls.env.ref("delivery.product_category_deliveries").id, + } + ) + cls.incoterm = cls.env["account.incoterms"].create( + {"name": "Incoterm", "code": "INC"} + ) + cls.intrastat_transport_mode = cls.env["intrastat.transport_mode"].create( + {"name": "Incoterm", "code": "INC", "description": "DESC"} + ) + cls.carrier = cls.env["delivery.carrier"].create( + { + "name": "Test carrier", + "delivery_type": "fixed", + "product_id": cls.product_delivery_1.id, + "incoterm": cls.incoterm.id, + "intrastat_transport_id": cls.intrastat_transport_mode.id, + } + ) + cls.order = cls.env["sale.order"].create( + { + "partner_id": cls.partner_a.id, + "order_line": [ + Command.create( + { + "product_id": cls.product_1.id, + } + ), + ], + } + ) + cls.journal_sale = cls.env["account.journal"].create( + { + "name": "Test journal sale", + "code": "TST-JRNL-S", + "type": "sale", + "company_id": cls.env.company.id, + } + ) + + def test_01_incoterms_intrastat_transport_propagation(self): + self.assertEqual(self.order.incoterm, self.env["account.incoterms"]) + self.assertEqual( + self.order.intrastat_transport_id, self.env["intrastat.transport_mode"] + ) + self.order.set_delivery_line(self.carrier, 0) + self.assertEqual(self.order.incoterm, self.env["account.incoterms"]) + self.assertEqual( + self.order.intrastat_transport_id, self.env["intrastat.transport_mode"] + ) + self.order.action_confirm() + self.assertEqual(self.order.incoterm, self.incoterm) + self.assertEqual( + self.order.intrastat_transport_id, self.intrastat_transport_mode + ) + self.context = { + "active_model": "sale.order", + "active_ids": [self.order.id], + "active_id": self.order.id, + "default_journal_id": self.journal_sale.id, + } + payment = ( + self.env["sale.advance.payment.inv"] + .with_context(**self.context) + .create({"advance_payment_method": "delivered"}) + ) + payment.create_invoices() + invoice = self.order.invoice_ids[0] + self.assertEqual(invoice.invoice_incoterm_id, self.incoterm) + self.assertEqual(invoice.intrastat_transport_id, self.intrastat_transport_mode) diff --git a/intrastat_delivery/views/delivery_carrier_view.xml b/intrastat_delivery/views/delivery_carrier_view.xml new file mode 100644 index 0000000..64590eb --- /dev/null +++ b/intrastat_delivery/views/delivery_carrier_view.xml @@ -0,0 +1,16 @@ + + + + + delivery.carrier.form.inherit + delivery.carrier + + + + + + + + + diff --git a/setup/intrastat_delivery/odoo/addons/intrastat_delivery b/setup/intrastat_delivery/odoo/addons/intrastat_delivery new file mode 120000 index 0000000..b291063 --- /dev/null +++ b/setup/intrastat_delivery/odoo/addons/intrastat_delivery @@ -0,0 +1 @@ +../../../../intrastat_delivery \ No newline at end of file diff --git a/setup/intrastat_delivery/setup.py b/setup/intrastat_delivery/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/intrastat_delivery/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)