Skip to content

Commit

Permalink
edi_sale_oca: split input to edi_sale_input_oca
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Nov 28, 2024
1 parent 0c2c550 commit 66cad70
Show file tree
Hide file tree
Showing 24 changed files with 151 additions and 181 deletions.
1 change: 1 addition & 0 deletions edi_sale_input_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bot please :)
2 changes: 2 additions & 0 deletions edi_sale_input_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import wizard
24 changes: 24 additions & 0 deletions edi_sale_input_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
1 change: 1 addition & 0 deletions edi_sale_input_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import process
File renamed without changes.
22 changes: 22 additions & 0 deletions edi_sale_input_oca/demo/edi_exchange_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>

<record id="demo_edi_exc_type_order_in" model="edi.exchange.type">
<field name="backend_type_id" ref="edi_sale_oca.demo_edi_backend_type_sale" />
<field name="backend_id" ref="edi_sale_oca.demo_edi_backend" />
<field name="name">Demo Sale Order</field>
<field name="code">demo_SaleOrder_in</field>
<field name="direction">input</field>
<field name="exchange_file_ext">xml</field>
<field name="advanced_settings_edit">
components:
process:
usage: input.process.sale.order
env_ctx:
default_price_source: 'pricelist'
default_import_type: 'xml'
random_key: custom
</field>
</record>

</odoo>
3 changes: 3 additions & 0 deletions edi_sale_input_oca/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Simone Orsi <[email protected]>
* Duong (Tran Quoc) <[email protected]>
* Thien (Vo Hong) <[email protected]>
1 change: 1 addition & 0 deletions edi_sale_input_oca/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp.
27 changes: 27 additions & 0 deletions edi_sale_input_oca/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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?
1 change: 1 addition & 0 deletions edi_sale_input_oca/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_process
51 changes: 51 additions & 0 deletions edi_sale_input_oca/tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <[email protected]>
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)
Expand Down
File renamed without changes.
File renamed without changes.
123 changes: 1 addition & 122 deletions edi_sale_oca/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/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 <https://github.com/OCA/edi/issues/new?body=module:%20edi_sale_oca%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* Simone Orsi <[email protected]>
* Duong (Tran Quoc) <[email protected]>
* Thien (Vo Hong) <[email protected]>

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 <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-simahawk|

This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/14.0/edi_sale_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
bot please :)
1 change: 0 additions & 1 deletion edi_sale_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from . import components
from . import models
from . import wizard
2 changes: 1 addition & 1 deletion edi_sale_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"depends": [
"edi_oca",
"edi_record_metadata_oca",
"sale_order_import",
"sale",
],
"data": [
"views/res_partner.xml",
Expand Down
1 change: 0 additions & 1 deletion edi_sale_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from . import process
20 changes: 3 additions & 17 deletions edi_sale_oca/demo/edi_exchange_type.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="demo_edi_exc_type_order_response_out" model="edi.exchange.type">
<field name="backend_type_id" ref="demo_edi_backend_type_sale" />
<field name="backend_id" ref="demo_edi_backend" />
<field name="name">Demo Sale Order Response</field>
<field name="code">demo_SaleOrderResponse_out</field>
<field name="direction">output</field>
<field name="exchange_filename_pattern">{record_name}-{type.code}-{dt}</field>
<field name="exchange_file_ext">xml</field>
<field name="advanced_settings_edit">
components:
generate:
usage: output.sale.generate.demo.OrderResponse
</field>
</record>

<record id="demo_edi_exc_type_order_in" model="edi.exchange.type">
<!-- TODO: add demo and tests for fake input/output exchanges. -->
<!-- <record id="demo_edi_exc_type_order_in" model="edi.exchange.type">
<field name="backend_type_id" ref="demo_edi_backend_type_sale" />
<field name="backend_id" ref="demo_edi_backend" />
<field name="ack_type_id" ref="demo_edi_exc_type_order_response_out" />
Expand All @@ -32,6 +18,6 @@ components:
default_import_type: 'xml'
random_key: custom
</field>
</record>
</record> -->

</odoo>
12 changes: 0 additions & 12 deletions edi_sale_oca/i18n/edi_sale_oca.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 5 additions & 25 deletions edi_sale_oca/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion edi_sale_oca/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from . import test_order
from . import test_process
1 change: 1 addition & 0 deletions setup/edi_sale_input_oca/odoo/addons/edi_sale_input_oca
6 changes: 6 additions & 0 deletions setup/edi_sale_input_oca/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 66cad70

Please sign in to comment.