Skip to content

Commit

Permalink
Merge PR #1075 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Nov 29, 2024
2 parents 56e83cf + f5c9ee1 commit dddad9a
Show file tree
Hide file tree
Showing 31 changed files with 205 additions and 254 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,5 @@ def _handle_create_order(self, order_id):
return order

def _handle_existing_order(self, order, message):
prev_record = self._get_previous_record(order)
self.exchange_record.message_post_with_view(
"edi_sale_oca.message_already_imported",
values={
"order": order,
"prev_record": prev_record,
"message": message,
"level": "info",
},
subtype_id=self.env.ref("mail.mt_note").id,
)

def _get_previous_record(self, order):
return self.env["edi.exchange.record"].search(
[("model", "=", "sale.order"), ("res_id", "=", order.id)], limit=1
)
# Hook
pass
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 @@ -3,7 +3,6 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import base64
import textwrap
from unittest import mock

from odoo.addons.component.tests.common import SavepointComponentCase
Expand All @@ -16,32 +15,17 @@ def setUpClass(cls):
super().setUpClass()
cls._setup_env()
cls.backend = cls._get_backend()
cls.exc_type = cls._create_exchange_type(
name="Test SO import",
code="test_so_import",
direction="input",
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:
process:
usage: input.process.sale.order
env_ctx:
default_price_source: 'pricelist'
default_import_type: 'xml'
random_key: custom
"""
),
)
cls.exc_type = cls.env.ref("edi_sale_input_oca.demo_edi_exc_type_order_in")
cls.record = cls.backend.create_record(
"test_so_import", {"edi_exchange_state": "input_received"}
cls.exc_type.code, {"edi_exchange_state": "input_received"}
)
cls.record._set_file_content(b"<fake><order></order></fake>")
cls.wiz_model = cls.env["sale.order.import"]

@classmethod
def _get_backend(cls):
return cls.env.ref("edi_sale_oca.demo_edi_backend")

def test_lookup(self):
comp = self.backend._get_component(self.record, "process")
self.assertEqual(comp._name, "edi.input.sale.order.process")
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
10 changes: 6 additions & 4 deletions edi_sale_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"summary": """
Configuration and special behaviors for EDI on sales.
""",
"version": "14.0.1.0.0",
"version": "14.0.2.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"author": "Camptocamp,Odoo Community Association (OCA)",
Expand All @@ -15,13 +15,15 @@
"depends": [
"edi_oca",
"edi_record_metadata_oca",
"sale_order_import",
"sale",
],
"data": [
"data/job_function.xml",
"views/res_partner.xml",
"views/sale_order.xml",
"views/edi_exchange_record.xml",
"templates/exchange_chatter_msg.xml",
],
"demo": [
"demo/edi_backend.xml",
"demo/edi_exchange_type.xml",
],
}
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
7 changes: 0 additions & 7 deletions edi_sale_oca/data/job_function.xml

This file was deleted.

11 changes: 11 additions & 0 deletions edi_sale_oca/demo/edi_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="demo_edi_backend_type_sale" model="edi.backend.type">
<field name="name">SALE DEMO</field>
<field name="code">sale_demo</field>
</record>
<record id="demo_edi_backend" model="edi.backend">
<field name="name">SALE DEMO</field>
<field name="backend_type_id" ref="demo_edi_backend_type_sale" />
</record>
</odoo>
Loading

0 comments on commit dddad9a

Please sign in to comment.