From 5d0bfac87e5f7183904cec9507b0daa7b3e1115b Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 28 Nov 2024 13:04:22 +0100 Subject: [PATCH] Split edi_sale_oca input to edi_sale_input_oca --- edi_sale_input_oca/README.rst | 1 + edi_sale_input_oca/__init__.py | 2 + edi_sale_input_oca/__manifest__.py | 24 ++++ edi_sale_input_oca/components/__init__.py | 1 + .../components/process.py | 0 edi_sale_input_oca/demo/edi_exchange_type.xml | 22 ++++ edi_sale_input_oca/readme/CONTRIBUTORS.rst | 3 + edi_sale_input_oca/readme/CREDITS.rst | 1 + edi_sale_input_oca/readme/DESCRIPTION.rst | 27 ++++ edi_sale_input_oca/tests/__init__.py | 1 + edi_sale_input_oca/tests/common.py | 51 ++++++++ .../tests/test_process.py | 2 +- .../wizard/__init__.py | 0 .../wizard/sale_order_import.py | 0 edi_sale_oca/README.rst | 123 +----------------- edi_sale_oca/__init__.py | 1 - edi_sale_oca/__manifest__.py | 2 +- edi_sale_oca/components/__init__.py | 1 - edi_sale_oca/demo/edi_exchange_type.xml | 20 +-- edi_sale_oca/i18n/edi_sale_oca.pot | 12 -- edi_sale_oca/readme/DESCRIPTION.rst | 30 +---- edi_sale_oca/tests/__init__.py | 1 - .../odoo/addons/edi_sale_input_oca | 1 + setup/edi_sale_input_oca/setup.py | 6 + 24 files changed, 151 insertions(+), 181 deletions(-) create mode 100644 edi_sale_input_oca/README.rst create mode 100644 edi_sale_input_oca/__init__.py create mode 100644 edi_sale_input_oca/__manifest__.py create mode 100644 edi_sale_input_oca/components/__init__.py rename {edi_sale_oca => edi_sale_input_oca}/components/process.py (100%) create mode 100644 edi_sale_input_oca/demo/edi_exchange_type.xml create mode 100644 edi_sale_input_oca/readme/CONTRIBUTORS.rst create mode 100644 edi_sale_input_oca/readme/CREDITS.rst create mode 100644 edi_sale_input_oca/readme/DESCRIPTION.rst create mode 100644 edi_sale_input_oca/tests/__init__.py create mode 100644 edi_sale_input_oca/tests/common.py rename {edi_sale_oca => edi_sale_input_oca}/tests/test_process.py (98%) rename {edi_sale_oca => edi_sale_input_oca}/wizard/__init__.py (100%) rename {edi_sale_oca => edi_sale_input_oca}/wizard/sale_order_import.py (100%) create mode 120000 setup/edi_sale_input_oca/odoo/addons/edi_sale_input_oca create mode 100644 setup/edi_sale_input_oca/setup.py diff --git a/edi_sale_input_oca/README.rst b/edi_sale_input_oca/README.rst new file mode 100644 index 00000000000..aab07cbf95b --- /dev/null +++ b/edi_sale_input_oca/README.rst @@ -0,0 +1 @@ +bot please :) diff --git a/edi_sale_input_oca/__init__.py b/edi_sale_input_oca/__init__.py new file mode 100644 index 00000000000..041e7ec2439 --- /dev/null +++ b/edi_sale_input_oca/__init__.py @@ -0,0 +1,2 @@ +from . import components +from . import wizard diff --git a/edi_sale_input_oca/__manifest__.py b/edi_sale_input_oca/__manifest__.py new file mode 100644 index 00000000000..2cc019ee9ba --- /dev/null +++ b/edi_sale_input_oca/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "EDI Sales input", + "summary": """ + Process incoming sale orders with the EDI framework. + """, + "version": "14.0.1.0.0", + "development_status": "Alpha", + "license": "AGPL-3", + "author": "Camptocamp,Odoo Community Association (OCA)", + "maintainers": ["simahawk"], + "website": "https://github.com/OCA/edi", + "depends": [ + "edi_sale_oca", + "edi_record_metadata_oca", + "sale_order_import", + ], + "data": [], + "demo": [ + "demo/edi_exchange_type.xml", + ], +} diff --git a/edi_sale_input_oca/components/__init__.py b/edi_sale_input_oca/components/__init__.py new file mode 100644 index 00000000000..bfb4ceb8483 --- /dev/null +++ b/edi_sale_input_oca/components/__init__.py @@ -0,0 +1 @@ +from . import process diff --git a/edi_sale_oca/components/process.py b/edi_sale_input_oca/components/process.py similarity index 100% rename from edi_sale_oca/components/process.py rename to edi_sale_input_oca/components/process.py diff --git a/edi_sale_input_oca/demo/edi_exchange_type.xml b/edi_sale_input_oca/demo/edi_exchange_type.xml new file mode 100644 index 00000000000..bec19fddc48 --- /dev/null +++ b/edi_sale_input_oca/demo/edi_exchange_type.xml @@ -0,0 +1,22 @@ + + + + + + + Demo Sale Order + demo_SaleOrder_in + input + xml + +components: + process: + usage: input.process.sale.order + env_ctx: + default_price_source: 'pricelist' + default_import_type: 'xml' + random_key: custom + + + + diff --git a/edi_sale_input_oca/readme/CONTRIBUTORS.rst b/edi_sale_input_oca/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..ab783cd7d3a --- /dev/null +++ b/edi_sale_input_oca/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Simone Orsi +* Duong (Tran Quoc) +* Thien (Vo Hong) diff --git a/edi_sale_input_oca/readme/CREDITS.rst b/edi_sale_input_oca/readme/CREDITS.rst new file mode 100644 index 00000000000..4c5b2fca2aa --- /dev/null +++ b/edi_sale_input_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_input_oca/readme/DESCRIPTION.rst b/edi_sale_input_oca/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..55cdc88ede1 --- /dev/null +++ b/edi_sale_input_oca/readme/DESCRIPTION.rst @@ -0,0 +1,27 @@ +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 + env_ctx: + # Values for the wizard + default_confirm_order: true + default_price_source: order + # Custom keys, whatever you need + random_one: true + +Note that `env_ctx` will propagate all keys to the whole env so you can use it +for any kind of context related configuration. In the case of the sale order import wizard +here we are just passing defaults as we could do in odoo standard. + +TODO: shall we add an exchange type example as demo? diff --git a/edi_sale_input_oca/tests/__init__.py b/edi_sale_input_oca/tests/__init__.py new file mode 100644 index 00000000000..c2bb451dd1a --- /dev/null +++ b/edi_sale_input_oca/tests/__init__.py @@ -0,0 +1 @@ +from . import test_process diff --git a/edi_sale_input_oca/tests/common.py b/edi_sale_input_oca/tests/common.py new file mode 100644 index 00000000000..523642abb62 --- /dev/null +++ b/edi_sale_input_oca/tests/common.py @@ -0,0 +1,51 @@ +# Copyright 2022 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields + + +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) + sale = cls._create_sale_order(**vals) + sale.action_confirm() + return sale diff --git a/edi_sale_oca/tests/test_process.py b/edi_sale_input_oca/tests/test_process.py similarity index 98% rename from edi_sale_oca/tests/test_process.py rename to edi_sale_input_oca/tests/test_process.py index bba078a018a..97924259893 100644 --- a/edi_sale_oca/tests/test_process.py +++ b/edi_sale_input_oca/tests/test_process.py @@ -15,7 +15,7 @@ def setUpClass(cls): super().setUpClass() cls._setup_env() cls.backend = cls._get_backend() - cls.exc_type = cls.env.ref("edi_sale_oca.demo_edi_exc_type_order_in") + cls.exc_type = cls.env.ref("edi_sale_input_oca.demo_edi_exc_type_order_in") cls.record = cls.backend.create_record( cls.exc_type.code, {"edi_exchange_state": "input_received"} ) diff --git a/edi_sale_oca/wizard/__init__.py b/edi_sale_input_oca/wizard/__init__.py similarity index 100% rename from edi_sale_oca/wizard/__init__.py rename to edi_sale_input_oca/wizard/__init__.py diff --git a/edi_sale_oca/wizard/sale_order_import.py b/edi_sale_input_oca/wizard/sale_order_import.py similarity index 100% rename from edi_sale_oca/wizard/sale_order_import.py rename to edi_sale_input_oca/wizard/sale_order_import.py diff --git a/edi_sale_oca/README.rst b/edi_sale_oca/README.rst index 136802b1209..aab07cbf95b 100644 --- a/edi_sale_oca/README.rst +++ b/edi_sale_oca/README.rst @@ -1,122 +1 @@ -========= -EDI Sales -========= - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:8cc00af990de28ee9679466fc10bfcfe395035c200137f800be3a5fbf69b987e - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |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_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_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| - -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 - env_ctx: - # Values for the wizard - default_confirm_order: true - default_price_source: order - # Custom keys, whatever you need - random_one: true - -Note that `env_ctx` will propagate all keys to the whole env so you can use it -for any kind of context related configuration. In the case of the sale order import wizard -here we are just passing defaults as we could do in odoo standard. - -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) -* Thien (Vo Hong) - -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 `_ project on GitHub. - -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. +bot please :) diff --git a/edi_sale_oca/__init__.py b/edi_sale_oca/__init__.py index d2243add246..f24d3e24261 100644 --- a/edi_sale_oca/__init__.py +++ b/edi_sale_oca/__init__.py @@ -1,3 +1,2 @@ from . import components from . import models -from . import wizard diff --git a/edi_sale_oca/__manifest__.py b/edi_sale_oca/__manifest__.py index 8a613d4fa25..ff39e600581 100644 --- a/edi_sale_oca/__manifest__.py +++ b/edi_sale_oca/__manifest__.py @@ -15,7 +15,7 @@ "depends": [ "edi_oca", "edi_record_metadata_oca", - "sale_order_import", + "sale", ], "data": [ "views/res_partner.xml", diff --git a/edi_sale_oca/components/__init__.py b/edi_sale_oca/components/__init__.py index bfb4ceb8483..e69de29bb2d 100644 --- a/edi_sale_oca/components/__init__.py +++ b/edi_sale_oca/components/__init__.py @@ -1 +0,0 @@ -from . import process diff --git a/edi_sale_oca/demo/edi_exchange_type.xml b/edi_sale_oca/demo/edi_exchange_type.xml index 8f144afa56e..49d9d08083f 100644 --- a/edi_sale_oca/demo/edi_exchange_type.xml +++ b/edi_sale_oca/demo/edi_exchange_type.xml @@ -1,21 +1,7 @@ - - - - Demo Sale Order Response - demo_SaleOrderResponse_out - output - {record_name}-{type.code}-{dt} - xml - -components: - generate: - usage: output.sale.generate.demo.OrderResponse - - - - + + diff --git a/edi_sale_oca/i18n/edi_sale_oca.pot b/edi_sale_oca/i18n/edi_sale_oca.pot index 97be8f73668..d089769fe72 100644 --- a/edi_sale_oca/i18n/edi_sale_oca.pot +++ b/edi_sale_oca/i18n/edi_sale_oca.pot @@ -176,18 +176,6 @@ msgstr "" msgid "Sales Order Line" msgstr "" -#. module: edi_sale_oca -#: code:addons/edi_sale_oca/components/process.py:0 -#, python-format -msgid "Sales order %s created" -msgstr "" - -#. module: edi_sale_oca -#: code:addons/edi_sale_oca/components/process.py:0 -#, python-format -msgid "Sales order has already been imported before" -msgstr "" - #. module: edi_sale_oca #: model_terms:ir.ui.view,arch_db:edi_sale_oca.view_sales_order_filter msgid "Source: EDI" diff --git a/edi_sale_oca/readme/DESCRIPTION.rst b/edi_sale_oca/readme/DESCRIPTION.rst index 55cdc88ede1..aa61922800a 100644 --- a/edi_sale_oca/readme/DESCRIPTION.rst +++ b/edi_sale_oca/readme/DESCRIPTION.rst @@ -1,27 +1,7 @@ -Inbound -~~~~~~~ -Receive sale orders from EDI channels. +Handle sale orders via EDI. -Control sale order confirmation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This is a base module to plug sales processes with the EDI framework. -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 - env_ctx: - # Values for the wizard - default_confirm_order: true - default_price_source: order - # Custom keys, whatever you need - random_one: true - -Note that `env_ctx` will propagate all keys to the whole env so you can use it -for any kind of context related configuration. In the case of the sale order import wizard -here we are just passing defaults as we could do in odoo standard. - -TODO: shall we add an exchange type example as demo? +To handle inbound/outbound sale orders, +you need to use `edi_sale_input_oca` or `edi_sale_output_oca` modules, +or create your own modules. diff --git a/edi_sale_oca/tests/__init__.py b/edi_sale_oca/tests/__init__.py index 80e52257884..e6fb64b6b64 100644 --- a/edi_sale_oca/tests/__init__.py +++ b/edi_sale_oca/tests/__init__.py @@ -1,2 +1 @@ from . import test_order -from . import test_process diff --git a/setup/edi_sale_input_oca/odoo/addons/edi_sale_input_oca b/setup/edi_sale_input_oca/odoo/addons/edi_sale_input_oca new file mode 120000 index 00000000000..3cdc497054b --- /dev/null +++ b/setup/edi_sale_input_oca/odoo/addons/edi_sale_input_oca @@ -0,0 +1 @@ +../../../../edi_sale_input_oca \ No newline at end of file diff --git a/setup/edi_sale_input_oca/setup.py b/setup/edi_sale_input_oca/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/edi_sale_input_oca/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)