diff --git a/edi_sale_ubl_oca/README.rst b/edi_sale_ubl_oca/README.rst index f8cab0d150..83e0b7c6f5 100644 --- a/edi_sale_ubl_oca/README.rst +++ b/edi_sale_ubl_oca/README.rst @@ -1 +1,81 @@ -bot, please, take care of this! \ No newline at end of file +========= +EDI Sales +========= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:af2db468de92ccb162f9d369aa2e73f7d86e42bdd13c9de7209d9bbb2e02df97 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fedi-lightgray.png?logo=github + :target: https://github.com/OCA/edi/tree/14.0/edi_sale_ubl_oca + :alt: OCA/edi +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-edi_sale_ubl_oca + :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/edi&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +TODO + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Simone Orsi + +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/edi `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/edi_sale_ubl_oca/__manifest__.py b/edi_sale_ubl_oca/__manifest__.py index 55a3944785..77003c0a58 100644 --- a/edi_sale_ubl_oca/__manifest__.py +++ b/edi_sale_ubl_oca/__manifest__.py @@ -14,6 +14,7 @@ "depends": [ "sale_order_import_ubl", "edi_sale_oca", + "edi_exchange_type_auto", "edi_ubl_oca", "edi_xml_oca", "edi_exchange_template_oca", diff --git a/edi_sale_ubl_oca/models/sale_order.py b/edi_sale_ubl_oca/models/sale_order.py index 117873c74c..f75fbbd9d5 100644 --- a/edi_sale_ubl_oca/models/sale_order.py +++ b/edi_sale_ubl_oca/models/sale_order.py @@ -12,6 +12,7 @@ class SaleOrder(models.Model): _name = "sale.order" _inherit = [ + "edi.auto.exchange.consumer.mixin", "sale.order", "edi.state.consumer.mixin", ] @@ -87,10 +88,10 @@ def create(self, vals_list): class SaleOrderLine(models.Model): _name = "sale.order.line" _inherit = [ - "sale.order.line", "edi.auto.exchange.consumer.mixin", "edi.id.mixin", "edi.state.consumer.mixin", + "sale.order.line", ] def _edi_determine_lines_state(self, orig_vals): diff --git a/edi_sale_ubl_oca/static/description/index.html b/edi_sale_ubl_oca/static/description/index.html new file mode 100644 index 0000000000..43ee174ea7 --- /dev/null +++ b/edi_sale_ubl_oca/static/description/index.html @@ -0,0 +1,426 @@ + + + + + +EDI Sales + + + +
+

EDI Sales

+ + +

Alpha License: AGPL-3 OCA/edi Translate me on Weblate Try me on Runboat

+

TODO

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

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

+
    +
  • Camptocamp
  • +
+
+ +
+

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

+

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

+
+
+
+ + diff --git a/edi_sale_ubl_oca/tests/common.py b/edi_sale_ubl_oca/tests/common.py index aabef12d82..2cf3e016dd 100644 --- a/edi_sale_ubl_oca/tests/common.py +++ b/edi_sale_ubl_oca/tests/common.py @@ -7,6 +7,7 @@ import xmlunittest +from odoo import fields from odoo.tests.common import SavepointCase from odoo.addons.sale_order_import_ubl.tests.common import get_test_data @@ -63,6 +64,7 @@ def _setup_inbound_order(cls, backend): ) cls.exc_type_in.backend_id = backend cls.exc_type_out.backend_id = backend + cls.exc_type_out.exchange_file_auto_generate = True cls.exc_record_in = backend.create_record( cls.exc_type_in.code, {"edi_exchange_state": "input_received"} ) @@ -84,3 +86,47 @@ def _find_order(self): ("commercial_partner_id", "=", self.order_data.partner.parent_id.id), ] ) + + +class OrderMixin(object): + @classmethod + def _create_sale_order(cls, **kw): + """Create a sale order + + :return: sale order + """ + model = cls.env["sale.order"] + vals = dict(commitment_date=fields.Date.today()) + vals.update(kw) + so_vals = model.play_onchanges(vals, []) + if "order_line" in so_vals: + so_vals["order_line"] = [(0, 0, x) for x in vals["order_line"]] + return model.create(so_vals) + + @classmethod + def _setup_order(cls, **kw): + cls.product_a = cls.env.ref("product.product_product_4") + cls.product_a.barcode = "1" * 14 + cls.product_b = cls.env.ref("product.product_product_4b") + cls.product_b.barcode = "2" * 14 + cls.product_c = cls.env.ref("product.product_product_4c") + cls.product_c.barcode = "3" * 14 + cls.product_d = cls.env.ref("product.product_product_5") + cls.product_d.barcode = "4" * 14 + line_defaults = kw.pop("line_defaults", {}) + vals = { + "partner_id": cls.env.ref("base.res_partner_10").id, + "commitment_date": "2022-07-29", + } + vals.update(kw) + if "client_order_ref" not in vals: + vals["client_order_ref"] = "ABC123" + vals["order_line"] = [ + {"product_id": cls.product_a.id, "product_uom_qty": 300, "edi_id": 1000}, + {"product_id": cls.product_b.id, "product_uom_qty": 200, "edi_id": 2000}, + {"product_id": cls.product_c.id, "product_uom_qty": 100, "edi_id": 3000}, + ] + if line_defaults: + for line in vals["order_line"]: + line.update(line_defaults) + cls.sale = cls._create_sale_order(**vals) diff --git a/edi_sale_ubl_oca/tests/test_order_in.py b/edi_sale_ubl_oca/tests/test_order_in.py index 0375957308..f723ba9087 100644 --- a/edi_sale_ubl_oca/tests/test_order_in.py +++ b/edi_sale_ubl_oca/tests/test_order_in.py @@ -5,18 +5,26 @@ from odoo import exceptions from odoo.tests.common import SavepointCase +from odoo.addons.component.tests.common import ComponentMixin from odoo.addons.edi_oca.tests.common import EDIBackendTestMixin from .common import OrderInboundTestMixin -class TestOrderInbound(SavepointCase, EDIBackendTestMixin, OrderInboundTestMixin): +class TestOrderInbound( + SavepointCase, EDIBackendTestMixin, OrderInboundTestMixin, ComponentMixin +): @classmethod def setUpClass(cls): super().setUpClass() + cls.setUpComponent() cls.backend = cls._get_backend() cls._setup_inbound_order(cls.backend) + def setUp(self): + super().setUp() + ComponentMixin.setUp(self) + @classmethod def _get_backend(cls): return cls.env.ref("edi_ubl_oca.edi_backend_ubl_demo") @@ -49,7 +57,7 @@ def test_existing_order(self): self.exc_record_in.action_exchange_process() self.assertEqual(self.exc_record_in.edi_exchange_state, "input_processed_error") err_msg = "Sales order has already been imported before" - self.assertEqual(self.exc_record_in.exchange_error, err_msg) + self.assertIn(err_msg, self.exc_record_in.exchange_error) def test_new_order(self): self.assertEqual(self.exc_record_in.edi_exchange_state, "input_received") @@ -72,7 +80,7 @@ def test_new_order(self): self.assertEqual(order.order_line.mapped("edi_id"), ["1", "2"]) self.assertTrue(order.edi_state_id.code, order.EDI_STATE_ORDER_ACCEPTED) self.assertTrue( - order.mapped("order_line.edi_state_id").code, + order.mapped("order_line.edi_state_id.code"), order.EDI_STATE_ORDER_LINE_ACCEPTED, ) diff --git a/edi_sale_ubl_oca/tests/test_order_in_full_flow.py b/edi_sale_ubl_oca/tests/test_order_in_full_flow.py index 3fd6470ff1..0dae0aaedf 100644 --- a/edi_sale_ubl_oca/tests/test_order_in_full_flow.py +++ b/edi_sale_ubl_oca/tests/test_order_in_full_flow.py @@ -5,6 +5,7 @@ from odoo import fields from odoo.tests.common import SavepointCase +from odoo.addons.component.tests.common import ComponentMixin from odoo.addons.edi_oca.tests.common import EDIBackendTestMixin from .common import OrderInboundTestMixin, get_xml_handler @@ -12,7 +13,9 @@ # TODO: split in different tests w/ SingleTransaction -class TestOrderInboundFull(SavepointCase, EDIBackendTestMixin, OrderInboundTestMixin): +class TestOrderInboundFull( + SavepointCase, EDIBackendTestMixin, OrderInboundTestMixin, ComponentMixin +): _schema_path = "base_ubl:data/xsd-2.2/maindoc/UBL-OrderResponse-2.2.xsd" @@ -20,6 +23,7 @@ class TestOrderInboundFull(SavepointCase, EDIBackendTestMixin, OrderInboundTestM def setUpClass(cls): super().setUpClass() cls._setup_env() + cls.setUpComponent() cls.backend = cls._get_backend() cls._setup_inbound_order(cls.backend) @@ -48,6 +52,7 @@ def test_new_order(self): ack_exc_record = order.exchange_record_ids.filtered( lambda x: x.type_id == self.exc_type_out ) + ack_exc_record.action_exchange_generate() file_content = ack_exc_record._get_file_content() self.assertTrue(file_content) # TMP / @@ -73,7 +78,7 @@ def test_new_order(self): ack_exc_record = order.exchange_record_ids.filtered( lambda x: x.type_id == self.exc_type_out and x != ack_exc_record ) - self.assertEqual(ack_exc_record.parent_id, self.exc_record_in) + ack_exc_record.action_exchange_generate() self.assertEqual(ack_exc_record.edi_exchange_state, "output_pending") file_content = ack_exc_record._get_file_content() self.assertTrue(file_content) diff --git a/edi_sale_ubl_oca/tests/test_order_response_out.py b/edi_sale_ubl_oca/tests/test_order_response_out.py index 7767af094a..fd04328dfc 100644 --- a/edi_sale_ubl_oca/tests/test_order_response_out.py +++ b/edi_sale_ubl_oca/tests/test_order_response_out.py @@ -4,12 +4,12 @@ from freezegun import freeze_time -from odoo.addons.edi_sale_oca.tests.common import OrderMixin +from odoo.addons.component.tests.common import ComponentMixin -from .common import XMLBaseTestCase, get_xml_handler +from .common import OrderMixin, XMLBaseTestCase, get_xml_handler -class TestOrderResponseOutbound(XMLBaseTestCase, OrderMixin): +class TestOrderResponseOutbound(XMLBaseTestCase, OrderMixin, ComponentMixin): maxDiff = None @@ -18,6 +18,7 @@ class TestOrderResponseOutbound(XMLBaseTestCase, OrderMixin): @classmethod def setUpClass(cls): super().setUpClass() + cls.setUpComponent() cls._setup_order() cls.exc_type_in = cls.env.ref("edi_sale_ubl_oca.demo_edi_exc_type_order_in") cls.exc_type_out = cls.env.ref( @@ -75,5 +76,6 @@ def test_xml(self): err = handler.validate(file_content) self.assertEqual(err, None, err) data = handler.parse_xml(file_content) - # TODO: test all main data - self.assertEqual(data["cbc:OrderResponseCode"], "AP") + # Order has not been created from exchange record input (just linked to record out), + # so all lines are not in Accepted state (AP) + self.assertEqual(data["cbc:OrderResponseCode"], "CA") diff --git a/edi_sale_ubl_oca/tests/test_order_state.py b/edi_sale_ubl_oca/tests/test_order_state.py index 51ed23d1bd..3043b26b77 100644 --- a/edi_sale_ubl_oca/tests/test_order_state.py +++ b/edi_sale_ubl_oca/tests/test_order_state.py @@ -4,14 +4,17 @@ from odoo.tests.common import SavepointCase +from odoo.addons.component.tests.common import ComponentMixin from odoo.addons.edi_oca.tests.common import EDIBackendTestMixin -from odoo.addons.edi_sale_oca.tests.common import OrderMixin +from .common import OrderMixin -class TestOrderInbound(SavepointCase, EDIBackendTestMixin, OrderMixin): + +class TestOrderInbound(SavepointCase, EDIBackendTestMixin, OrderMixin, ComponentMixin): @classmethod def setUpClass(cls): super().setUpClass() + cls.setUpComponent() # force metadata storage w/ proper key cls.env = cls.env(context=dict(cls.env.context, edi_framework_action=True)) cls.backend = cls._get_backend() @@ -24,6 +27,11 @@ def setUpClass(cls): line_defaults=dict(origin_exchange_record_id=cls.exc_record_in.id), ) + def setUp(self): + super().setUp() + ComponentMixin.setUp(self) + self.sale.action_confirm() + @classmethod def _get_backend(cls): return cls.env.ref("edi_ubl_oca.edi_backend_ubl_demo") diff --git a/setup/edi_sale_ubl_oca/odoo/addons/edi_sale_ubl_oca b/setup/edi_sale_ubl_oca/odoo/addons/edi_sale_ubl_oca new file mode 120000 index 0000000000..8bed21b906 --- /dev/null +++ b/setup/edi_sale_ubl_oca/odoo/addons/edi_sale_ubl_oca @@ -0,0 +1 @@ +../../../../edi_sale_ubl_oca \ No newline at end of file diff --git a/setup/edi_sale_ubl_oca/setup.py b/setup/edi_sale_ubl_oca/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/edi_sale_ubl_oca/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)