diff --git a/edi_purchase_oca/README.rst b/edi_purchase_oca/README.rst new file mode 100644 index 000000000..00e502066 --- /dev/null +++ b/edi_purchase_oca/README.rst @@ -0,0 +1,93 @@ +============ +EDI Purchase +============ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8ab40ab13f4a26ea0ba04ff19e53af88e490d1b2e783699454ae6255422e00c3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi--framework-lightgray.png?logo=github + :target: https://github.com/OCA/edi-framework/tree/18.0/edi_purchase_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-18-0/edi-framework-18-0-edi_purchase_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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module intends to create a base to be extended by local edi rules +for purchase. + +In order to add a new integration, you need to create a listener: + +.. code:: python + + class MyEventListener(Component): + _name = "purchase.order.event.listener.demo" + _inherit = "base.event.listener" + _apply_on = ["purchase.order"] + + def on_button_confirm_purchase_order(self, move): + """Add your code here""" + +**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 +------- + +* ForgeFlow +* Camptocamp + +Contributors +------------ + +- Lois Rilo lois.rilo@forgeflow.com +- Simone Orsi simone.orsi@camptocamp.com + +- Phan Hong Phuc + +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-framework `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/edi_purchase_oca/__init__.py b/edi_purchase_oca/__init__.py new file mode 100644 index 000000000..0f00a6730 --- /dev/null +++ b/edi_purchase_oca/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import components diff --git a/edi_purchase_oca/__manifest__.py b/edi_purchase_oca/__manifest__.py new file mode 100644 index 000000000..1d5d9ac59 --- /dev/null +++ b/edi_purchase_oca/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "EDI Purchase", + "summary": """ + Define EDI Configuration for Purchase Orders""", + "version": "18.0.1.0.0", + "license": "LGPL-3", + "author": "ForgeFlow, Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/edi-framework", + "depends": ["purchase", "edi_oca", "component_event"], + "data": [ + "views/purchase_order_views.xml", + "views/edi_exchange_record_views.xml", + "views/res_partner_view.xml", + "data/edi_configuration.xml", + ], + "demo": [ + "demo/edi_backend.xml", + "demo/edi_exchange_type.xml", + "demo/edi_configuration.xml", + ], +} diff --git a/edi_purchase_oca/components/__init__.py b/edi_purchase_oca/components/__init__.py new file mode 100644 index 000000000..a441d8bd1 --- /dev/null +++ b/edi_purchase_oca/components/__init__.py @@ -0,0 +1 @@ +from . import listeners diff --git a/edi_purchase_oca/components/listeners.py b/edi_purchase_oca/components/listeners.py new file mode 100644 index 000000000..a29013ee4 --- /dev/null +++ b/edi_purchase_oca/components/listeners.py @@ -0,0 +1,27 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.component.core import Component + + +class EDIConfigPOListener(Component): + _name = "edi.listener.config.purchase.order" + _inherit = "base.event.listener" + _apply_on = ["purchase.order"] + + def on_record_create(self, record, fields=None): + trigger = "on_record_create" + return self._exec_conf(record, trigger) + + def on_record_write(self, record, fields=None): + trigger = "on_record_write" + return self._exec_conf(record, trigger) + + def on_edi_purchase_order_state_change(self, record, state=None): + trigger = "on_edi_purchase_order_state_change" + return self._exec_conf(record, trigger) + + def _exec_conf(self, record, trigger, conf_field="edi_purchase_conf_ids"): + confs = record.partner_id[conf_field].edi_get_conf(trigger) + for conf in confs: + conf.edi_exec_snippet_do(record) diff --git a/edi_purchase_oca/data/edi_configuration.xml b/edi_purchase_oca/data/edi_configuration.xml new file mode 100644 index 000000000..41417f92c --- /dev/null +++ b/edi_purchase_oca/data/edi_configuration.xml @@ -0,0 +1,13 @@ + + + + + On PO state change + on_edi_purchase_order_state_change + Trigger when a purchase order state changes + + + diff --git a/edi_purchase_oca/demo/edi_backend.xml b/edi_purchase_oca/demo/edi_backend.xml new file mode 100644 index 000000000..3410efd87 --- /dev/null +++ b/edi_purchase_oca/demo/edi_backend.xml @@ -0,0 +1,11 @@ + + + + Purchase DEMO + purchase_demo + + + purchase DEMO + + + diff --git a/edi_purchase_oca/demo/edi_configuration.xml b/edi_purchase_oca/demo/edi_configuration.xml new file mode 100644 index 000000000..b22172f81 --- /dev/null +++ b/edi_purchase_oca/demo/edi_configuration.xml @@ -0,0 +1,23 @@ + + + + Demo PO send + Show case how you can send out an order automatically + + + + + +# ('draft', 'RFQ'), +# ('sent', 'RFQ Sent'), +# ('to approve', 'To Approve'), +# ('purchase', 'Purchase Order'), +# ('done', 'Locked'), +# ('cancel', 'Cancelled') +if record.state == 'purchase': + record._edi_send_via_edi(conf.type_id) + + + diff --git a/edi_purchase_oca/demo/edi_exchange_type.xml b/edi_purchase_oca/demo/edi_exchange_type.xml new file mode 100644 index 000000000..161349aae --- /dev/null +++ b/edi_purchase_oca/demo/edi_exchange_type.xml @@ -0,0 +1,12 @@ + + + + + + Demo Purchase Order out + demo_PurchaseOrder_out + output + {record_name}-{type.code}-{dt} + xml + + diff --git a/edi_purchase_oca/i18n/edi_purchase_oca.pot b/edi_purchase_oca/i18n/edi_purchase_oca.pot new file mode 100644 index 000000000..be7f21321 --- /dev/null +++ b/edi_purchase_oca/i18n/edi_purchase_oca.pot @@ -0,0 +1,122 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_purchase_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-12-31 04:47+0000\n" +"PO-Revision-Date: 2025-12-31 04:47+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: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "EDI" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model,name:edi_purchase_oca.model_res_partner +msgid "Contact" +msgstr "" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "Disable" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__edi_disable_auto +msgid "Disable auto" +msgstr "" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "EDI" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__origin_exchange_type_id +msgid "EDI origin exchange type" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__origin_exchange_record_id +msgid "EDI origin record" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_res_partner__edi_purchase_conf_ids +#: model:ir.model.fields,field_description:edi_purchase_oca.field_res_users__edi_purchase_conf_ids +msgid "EDI purchase configuration" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,help:edi_purchase_oca.field_purchase_order__origin_exchange_record_id +msgid "EDI record that originated this document." +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__edi_config +msgid "Edi Config" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__edi_has_form_config +msgid "Edi Has Form Config" +msgstr "" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "Electronic Data Interchange" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__exchange_record_ids +msgid "Exchange Record" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__exchange_record_count +msgid "Exchange Record Count" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__exchange_related_record_ids +msgid "Exchange Related Record" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.ui.menu,name:edi_purchase_oca.menu_purchase_edi_root +msgid "Exchange records" +msgstr "" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.view_partner_form +msgid "Purchase" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model,name:edi_purchase_oca.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.actions.act_window,name:edi_purchase_oca.act_open_edi_exchange_record_purchase_order_view +msgid "Purchase Order Exchange Record" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.ui.menu,name:edi_purchase_oca.menu_purchase_edi_exchange_record +msgid "Purchase Orders" +msgstr "" + +#. module: edi_purchase_oca +#: model:ir.model.fields,help:edi_purchase_oca.field_purchase_order__edi_disable_auto +msgid "When marked, EDI automatic processing will be avoided" +msgstr "" diff --git a/edi_purchase_oca/i18n/es.po b/edi_purchase_oca/i18n/es.po new file mode 100644 index 000000000..7d7a6b930 --- /dev/null +++ b/edi_purchase_oca/i18n/es.po @@ -0,0 +1,122 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_purchase_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-12-31 04:48+0000\n" +"PO-Revision-Date: 2025-12-31 04:48+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: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "EDI" +msgstr "EDI" + +#. module: edi_purchase_oca +#: model:ir.model,name:edi_purchase_oca.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "Disable" +msgstr "Desactivar" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__edi_disable_auto +msgid "Disable auto" +msgstr "Desactivar automático" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "EDI" +msgstr "EDI" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__origin_exchange_type_id +msgid "EDI origin exchange type" +msgstr "Tipo de intercambio de origen EDI" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__origin_exchange_record_id +msgid "EDI origin record" +msgstr "Registro de origen EDI" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_res_partner__edi_purchase_conf_ids +#: model:ir.model.fields,field_description:edi_purchase_oca.field_res_users__edi_purchase_conf_ids +msgid "EDI purchase configuration" +msgstr "Configuración de compra EDI" + +#. module: edi_purchase_oca +#: model:ir.model.fields,help:edi_purchase_oca.field_purchase_order__origin_exchange_record_id +msgid "EDI record that originated this document." +msgstr "Registro EDI que originó este documento" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__edi_config +msgid "Edi Config" +msgstr "Configuración EDI" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__edi_has_form_config +msgid "Edi Has Form Config" +msgstr "EDI tiene configuración de formulario" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.purchase_order_form +msgid "Electronic Data Interchange" +msgstr "Intercambio Electrónico de Datos" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__exchange_record_ids +msgid "Exchange Record" +msgstr "Registro de intercambio" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__exchange_record_count +msgid "Exchange Record Count" +msgstr "Conteo de registros de intercambio" + +#. module: edi_purchase_oca +#: model:ir.model.fields,field_description:edi_purchase_oca.field_purchase_order__exchange_related_record_ids +msgid "Exchange Related Record" +msgstr "Registro relacionado con el intercambio" + +#. module: edi_purchase_oca +#: model:ir.ui.menu,name:edi_purchase_oca.menu_purchase_edi_root +msgid "Exchange records" +msgstr "Registros de intercambio" + +#. module: edi_purchase_oca +#: model_terms:ir.ui.view,arch_db:edi_purchase_oca.view_partner_form +msgid "Purchase" +msgstr "Compra" + +#. module: edi_purchase_oca +#: model:ir.model,name:edi_purchase_oca.model_purchase_order +msgid "Purchase Order" +msgstr "Orden de compra" + +#. module: edi_purchase_oca +#: model:ir.actions.act_window,name:edi_purchase_oca.act_open_edi_exchange_record_purchase_order_view +msgid "Purchase Order Exchange Record" +msgstr "Registro de intercambio de la orden de compra" + +#. module: edi_purchase_oca +#: model:ir.ui.menu,name:edi_purchase_oca.menu_purchase_edi_exchange_record +msgid "Purchase Orders" +msgstr "Órdenes de compra" + +#. module: edi_purchase_oca +#: model:ir.model.fields,help:edi_purchase_oca.field_purchase_order__edi_disable_auto +msgid "When marked, EDI automatic processing will be avoided" +msgstr "Cuando se marque, se evitará el procesamiento automático de EDI" diff --git a/edi_purchase_oca/models/__init__.py b/edi_purchase_oca/models/__init__.py new file mode 100644 index 000000000..abb5aa08a --- /dev/null +++ b/edi_purchase_oca/models/__init__.py @@ -0,0 +1,2 @@ +from . import purchase_order +from . import res_partner diff --git a/edi_purchase_oca/models/purchase_order.py b/edi_purchase_oca/models/purchase_order.py new file mode 100644 index 000000000..a2f5910d0 --- /dev/null +++ b/edi_purchase_oca/models/purchase_order.py @@ -0,0 +1,32 @@ +# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from contextlib import contextmanager + +from odoo import models + + +class PurchaseOrder(models.Model): + _name = "purchase.order" + _inherit = [ + "purchase.order", + "edi.exchange.consumer.mixin", + ] + + def button_confirm(self): + with self._edi_purchase_order_state_change_trigger(): + result = super().button_confirm() + return result + + def button_cancel(self): + with self._edi_purchase_order_state_change_trigger(): + result = super().button_cancel() + return result + + @contextmanager + def _edi_purchase_order_state_change_trigger(self): + for order in self: + order._event("on_edi_purchase_order_state_change").notify( + order, state=order.state + ) + yield diff --git a/edi_purchase_oca/models/res_partner.py b/edi_purchase_oca/models/res_partner.py new file mode 100644 index 000000000..7c38d54b4 --- /dev/null +++ b/edi_purchase_oca/models/res_partner.py @@ -0,0 +1,18 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + edi_purchase_conf_ids = fields.Many2many( + string="EDI purchase configuration", + comodel_name="edi.configuration", + relation="res_partner_edi_purchase_configuration_rel", + column1="partner_id", + column2="conf_id", + domain=[("model_name", "=", "purchase.order")], + ) diff --git a/edi_purchase_oca/pyproject.toml b/edi_purchase_oca/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/edi_purchase_oca/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/edi_purchase_oca/readme/CONTRIBUTORS.md b/edi_purchase_oca/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..8f84d0756 --- /dev/null +++ b/edi_purchase_oca/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +* Lois Rilo +* Simone Orsi +- Phan Hong Phuc \<\> diff --git a/edi_purchase_oca/readme/DESCRIPTION.md b/edi_purchase_oca/readme/DESCRIPTION.md new file mode 100644 index 000000000..4ea283bc2 --- /dev/null +++ b/edi_purchase_oca/readme/DESCRIPTION.md @@ -0,0 +1,14 @@ +This module intends to create a base to be extended by local edi rules +for purchase. + +In order to add a new integration, you need to create a listener: + +``` python +class MyEventListener(Component): + _name = "purchase.order.event.listener.demo" + _inherit = "base.event.listener" + _apply_on = ["purchase.order"] + + def on_button_confirm_purchase_order(self, move): + """Add your code here""" +``` diff --git a/edi_purchase_oca/static/description/icon.png b/edi_purchase_oca/static/description/icon.png new file mode 100644 index 000000000..a79752645 Binary files /dev/null and b/edi_purchase_oca/static/description/icon.png differ diff --git a/edi_purchase_oca/static/description/index.html b/edi_purchase_oca/static/description/index.html new file mode 100644 index 000000000..d7c068c61 --- /dev/null +++ b/edi_purchase_oca/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +EDI Purchase + + + +
+

EDI Purchase

+ + +

Beta License: LGPL-3 OCA/edi-framework Translate me on Weblate Try me on Runboat

+

This module intends to create a base to be extended by local edi rules +for purchase.

+

In order to add a new integration, you need to create a listener:

+
+class MyEventListener(Component):
+    _name = "purchase.order.event.listener.demo"
+    _inherit = "base.event.listener"
+    _apply_on = ["purchase.order"]
+
+    def on_button_confirm_purchase_order(self, move):
+        """Add your code here"""
+
+

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

+
    +
  • ForgeFlow
  • +
  • Camptocamp
  • +
+
+
+

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/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_purchase_oca/tests/__init__.py b/edi_purchase_oca/tests/__init__.py new file mode 100644 index 000000000..2c35aec6f --- /dev/null +++ b/edi_purchase_oca/tests/__init__.py @@ -0,0 +1 @@ +from . import test_edi_conf diff --git a/edi_purchase_oca/tests/test_edi_conf.py b/edi_purchase_oca/tests/test_edi_conf.py new file mode 100644 index 000000000..a0be7a081 --- /dev/null +++ b/edi_purchase_oca/tests/test_edi_conf.py @@ -0,0 +1,55 @@ +# Copyright 2024 CamptoCamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from unittest import mock + +from odoo import Command + +from odoo.addons.edi_oca.tests.common import EDIBackendCommonComponentTestCase + + +class TestsPurchaseEDIConfiguration(EDIBackendCommonComponentTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.purchase_order = cls.env["purchase.order"] + cls.product = cls.env["product.product"].create( + { + "name": "Product 1", + "default_code": "1234567", + } + ) + cls.exc_type_out = cls.env.ref("edi_purchase_oca.demo_edi_exc_type_order_out") + cls.edi_conf = cls.env.ref("edi_purchase_oca.demo_edi_configuration_confirmed") + cls.partner.edi_purchase_conf_ids = cls.edi_conf + + @mock.patch("odoo.addons.edi_core_oca.models.edi_backend.EDIBackend._validate_data") + @mock.patch( + "odoo.addons.edi_core_oca.models.edi_backend.EDIBackend._exchange_generate" + ) + @mock.patch("odoo.addons.edi_core_oca.models.edi_backend.EDIBackend._exchange_send") + def test_order_confirm(self, mock_send, mock_generate, mock_validate): + mock_generate.return_value = "TEST PO OUT" + order = self.purchase_order.create( + { + "partner_id": self.partner.id, + "order_line": [ + Command.create( + { + "product_id": self.product.id, + "product_qty": 10, + "price_unit": 100.0, + } + ), + ], + } + ) + self.assertEqual(order.state, "draft") + self.assertEqual(len(order.exchange_record_ids), 0) + order.button_confirm() + self.assertEqual(order.state, "purchase") + self.assertEqual(len(order.exchange_record_ids), 1) + self.assertEqual(order.exchange_record_ids[0].type_id, self.exc_type_out) + self.assertEqual( + order.exchange_record_ids[0]._get_file_content(), "TEST PO OUT" + ) diff --git a/edi_purchase_oca/views/edi_exchange_record_views.xml b/edi_purchase_oca/views/edi_exchange_record_views.xml new file mode 100644 index 000000000..89b4f0921 --- /dev/null +++ b/edi_purchase_oca/views/edi_exchange_record_views.xml @@ -0,0 +1,29 @@ + + + + + Purchase Order Exchange Record + ir.actions.act_window + edi.exchange.record + list,form + [('model', '=', 'purchase.order')] + {} + + + + diff --git a/edi_purchase_oca/views/purchase_order_views.xml b/edi_purchase_oca/views/purchase_order_views.xml new file mode 100644 index 000000000..b6d4c6799 --- /dev/null +++ b/edi_purchase_oca/views/purchase_order_views.xml @@ -0,0 +1,38 @@ + + + + + purchase.order.form - edi_purchase_oca + purchase.order + + + + + + + + + + + + + + + diff --git a/edi_purchase_oca/views/res_partner_view.xml b/edi_purchase_oca/views/res_partner_view.xml new file mode 100644 index 000000000..f950cc0d3 --- /dev/null +++ b/edi_purchase_oca/views/res_partner_view.xml @@ -0,0 +1,22 @@ + + + + res.partner.edi.purchase + res.partner + + + + + + + + + + + + + + + + +