From f5b1a41f76685c32e112ad6d5b498edddcd14400 Mon Sep 17 00:00:00 2001 From: duongtq Date: Wed, 18 Oct 2023 10:55:58 +0700 Subject: [PATCH] [MIG] edi_sale_oca: Migration to 16.0 --- edi_sale_oca/README.rst | 118 +++++- edi_sale_oca/__manifest__.py | 4 +- edi_sale_oca/components/process.py | 2 +- edi_sale_oca/models/sale_order.py | 4 +- edi_sale_oca/readme/CONTRIBUTORS.rst | 1 + edi_sale_oca/readme/CREDITS.rst | 1 + edi_sale_oca/readme/DESCRIPTION.rst | 2 +- edi_sale_oca/static/description/index.html | 448 +++++++++++++++++++++ edi_sale_oca/tests/test_order.py | 6 +- edi_sale_oca/tests/test_process.py | 10 +- edi_sale_oca/views/sale_order.xml | 4 +- 11 files changed, 583 insertions(+), 17 deletions(-) create mode 100644 edi_sale_oca/readme/CREDITS.rst create mode 100644 edi_sale_oca/static/description/index.html diff --git a/edi_sale_oca/README.rst b/edi_sale_oca/README.rst index 40734932d..62c0684d2 100644 --- a/edi_sale_oca/README.rst +++ b/edi_sale_oca/README.rst @@ -1 +1,117 @@ -bot yet to come +========= +EDI Sales +========= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:025dc95e2d51d0445893506bfd24f2341979ed31c5d9fced6ed5f8fa90ab0027 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--framework-lightgray.png?logo=github + :target: https://github.com/OCA/edi-framework/tree/16.0/edi_sale_oca + :alt: OCA/edi-framework +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-framework-16-0/edi-framework-16-0-edi_sale_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-framework&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +TODO + +Inbound +~~~~~~~ +Receive sale orders from EDI channels. + +Control sale order confirmation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can decide if the order should be confirmed by exchange type. + +On your exchange type, go to advanced settings and add the following:: + + [...] + components: + process: + usage: input.process.sale.order + [...] + sale_order: + default_confirm_order: true + + +TODO: shall we add an exchange type example as demo? + +.. 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 +* Duong (Tran Quoc) + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp. + +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. + +.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px + :target: https://github.com/simahawk + :alt: simahawk + +Current `maintainer `__: + +|maintainer-simahawk| + +This module is part of the `OCA/edi-framework `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/edi_sale_oca/__manifest__.py b/edi_sale_oca/__manifest__.py index b469cdc1f..901509357 100644 --- a/edi_sale_oca/__manifest__.py +++ b/edi_sale_oca/__manifest__.py @@ -6,12 +6,12 @@ "summary": """ Configuration and special behaviors for EDI on sales. """, - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "development_status": "Alpha", "license": "AGPL-3", "author": "Camptocamp,Odoo Community Association (OCA)", "maintainers": ["simahawk"], - "website": "https://github.com/OCA/edi", + "website": "https://github.com/OCA/edi-framework", "depends": [ "edi_oca", "edi_record_metadata_oca", diff --git a/edi_sale_oca/components/process.py b/edi_sale_oca/components/process.py index 4b31fd892..7169968a8 100644 --- a/edi_sale_oca/components/process.py +++ b/edi_sale_oca/components/process.py @@ -83,7 +83,7 @@ def _handle_create_order(self, order_id): def _handle_existing_order(self, order, message): prev_record = self._get_previous_record(order) self.exchange_record.message_post_with_view( - "edi_sale_order_import.message_already_imported", + "edi_sale_oca.message_already_imported", values={ "order": order, "prev_record": prev_record, diff --git a/edi_sale_oca/models/sale_order.py b/edi_sale_oca/models/sale_order.py index 7e3f23e29..bd025230f 100644 --- a/edi_sale_oca/models/sale_order.py +++ b/edi_sale_oca/models/sale_order.py @@ -23,7 +23,7 @@ class SaleOrder(models.Model): # and ask the sender to issue a new order request. # This approach seems suitable only for orders that do not get processed immediately. - disable_edi_auto = fields.Boolean( + edi_disable_auto = fields.Boolean( states={"draft": [("readonly", False)]}, ) @@ -49,7 +49,7 @@ class SaleOrderLine(models.Model): "edi.id.mixin", ] - disable_edi_auto = fields.Boolean(related="order_id.disable_edi_auto") + edi_disable_auto = fields.Boolean(related="order_id.edi_disable_auto") # TODO: add test edi_exchange_ready = fields.Boolean(compute="_compute_edi_exchange_ready") diff --git a/edi_sale_oca/readme/CONTRIBUTORS.rst b/edi_sale_oca/readme/CONTRIBUTORS.rst index f1c71bce1..20b0da936 100644 --- a/edi_sale_oca/readme/CONTRIBUTORS.rst +++ b/edi_sale_oca/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Simone Orsi +* Duong (Tran Quoc) diff --git a/edi_sale_oca/readme/CREDITS.rst b/edi_sale_oca/readme/CREDITS.rst new file mode 100644 index 000000000..4c5b2fca2 --- /dev/null +++ b/edi_sale_oca/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp. diff --git a/edi_sale_oca/readme/DESCRIPTION.rst b/edi_sale_oca/readme/DESCRIPTION.rst index c66a89709..a8ef59a50 100644 --- a/edi_sale_oca/readme/DESCRIPTION.rst +++ b/edi_sale_oca/readme/DESCRIPTION.rst @@ -17,7 +17,7 @@ On your exchange type, go to advanced settings and add the following:: usage: input.process.sale.order [...] sale_order: - confirm_order: true + default_confirm_order: true TODO: shall we add an exchange type example as demo? diff --git a/edi_sale_oca/static/description/index.html b/edi_sale_oca/static/description/index.html new file mode 100644 index 000000000..d3caef493 --- /dev/null +++ b/edi_sale_oca/static/description/index.html @@ -0,0 +1,448 @@ + + + + + + +EDI Sales + + + +
+

EDI Sales

+ + +

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

+

TODO

+
+

Inbound

+

Receive sale orders from EDI channels.

+
+
+

Control sale order confirmation

+

You can decide if the order should be confirmed by exchange type.

+

On your exchange type, go to advanced settings and add the following:

+
+[...]
+components:
+    process:
+        usage: input.process.sale.order
+[...]
+sale_order:
+    default_confirm_order: true
+
+

TODO: shall we add an exchange type example as demo?

+
+

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.

+
+ +
+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 14.0 to 16.0 was financially supported by 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.

+

Current maintainer:

+

simahawk

+

This module is part of the OCA/edi-framework project on GitHub.

+

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

+
+
+ + diff --git a/edi_sale_oca/tests/test_order.py b/edi_sale_oca/tests/test_order.py index 3f231c380..ad91d79c2 100644 --- a/edi_sale_oca/tests/test_order.py +++ b/edi_sale_oca/tests/test_order.py @@ -2,14 +2,14 @@ # @author: Simone Orsi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase from odoo.addons.edi_oca.tests.common import EDIBackendTestMixin from .common import OrderMixin -class TestOrder(SavepointCase, EDIBackendTestMixin, OrderMixin): +class TestOrder(TransactionCase, EDIBackendTestMixin, OrderMixin): @classmethod def setUpClass(cls): super().setUpClass() @@ -44,7 +44,7 @@ def test_line_origin(self): }, ] ) - order.invalidate_cache() + order.env.invalidate_all() new_line1, new_line2 = order.order_line - lines self.assertEqual(new_line1.origin_exchange_record_id, self.exc_record_in) self.assertEqual(new_line2.origin_exchange_record_id, self.exc_record_in) diff --git a/edi_sale_oca/tests/test_process.py b/edi_sale_oca/tests/test_process.py index 633ef24ed..a5ce4363d 100644 --- a/edi_sale_oca/tests/test_process.py +++ b/edi_sale_oca/tests/test_process.py @@ -4,14 +4,13 @@ import base64 import textwrap +from unittest import mock -import mock - -from odoo.addons.component.tests.common import SavepointComponentCase +from odoo.addons.component.tests.common import TransactionComponentCase from odoo.addons.edi_oca.tests.common import EDIBackendTestMixin -class TestProcessComponent(SavepointComponentCase, EDIBackendTestMixin): +class TestProcessComponent(TransactionComponentCase, EDIBackendTestMixin): @classmethod def setUpClass(cls): super().setUpClass() @@ -24,6 +23,7 @@ def setUpClass(cls): exchange_file_ext="xml", exchange_filename_pattern="{record.identifier}-{type.code}-{dt}", backend_id=cls.backend.id, + # Bypass required fields with default_import_type = 'xml' in sale_order_import advanced_settings_edit=textwrap.dedent( """ components: @@ -32,6 +32,7 @@ def setUpClass(cls): sale_order_import: wiz_ctx: random_key: custom + default_import_type: 'xml' """ ), ) @@ -155,7 +156,6 @@ def test_metadata(self): "product_id", "product_uom_qty", "product_uom", - "name", "price_unit", "edi_id", ): diff --git a/edi_sale_oca/views/sale_order.xml b/edi_sale_oca/views/sale_order.xml index a95bd268f..857129b38 100644 --- a/edi_sale_oca/views/sale_order.xml +++ b/edi_sale_oca/views/sale_order.xml @@ -11,7 +11,7 @@ @@ -42,7 +42,7 @@