Skip to content

Commit dddad9a

Browse files
committed
Merge PR #1075 into 14.0
Signed-off-by simahawk
2 parents 56e83cf + f5c9ee1 commit dddad9a

31 files changed

+205
-254
lines changed

edi_sale_input_oca/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bot please :)

edi_sale_input_oca/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import components
2+
from . import wizard

edi_sale_input_oca/__manifest__.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2022 Camptocamp SA
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "EDI Sales input",
6+
"summary": """
7+
Process incoming sale orders with the EDI framework.
8+
""",
9+
"version": "14.0.1.0.0",
10+
"development_status": "Alpha",
11+
"license": "AGPL-3",
12+
"author": "Camptocamp,Odoo Community Association (OCA)",
13+
"maintainers": ["simahawk"],
14+
"website": "https://github.com/OCA/edi",
15+
"depends": [
16+
"edi_sale_oca",
17+
"edi_record_metadata_oca",
18+
"sale_order_import",
19+
],
20+
"data": [],
21+
"demo": [
22+
"demo/edi_exchange_type.xml",
23+
],
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import process

edi_sale_oca/components/process.py edi_sale_input_oca/components/process.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,5 @@ def _handle_create_order(self, order_id):
6161
return order
6262

6363
def _handle_existing_order(self, order, message):
64-
prev_record = self._get_previous_record(order)
65-
self.exchange_record.message_post_with_view(
66-
"edi_sale_oca.message_already_imported",
67-
values={
68-
"order": order,
69-
"prev_record": prev_record,
70-
"message": message,
71-
"level": "info",
72-
},
73-
subtype_id=self.env.ref("mail.mt_note").id,
74-
)
75-
76-
def _get_previous_record(self, order):
77-
return self.env["edi.exchange.record"].search(
78-
[("model", "=", "sale.order"), ("res_id", "=", order.id)], limit=1
79-
)
64+
# Hook
65+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<odoo>
3+
4+
<record id="demo_edi_exc_type_order_in" model="edi.exchange.type">
5+
<field name="backend_type_id" ref="edi_sale_oca.demo_edi_backend_type_sale" />
6+
<field name="backend_id" ref="edi_sale_oca.demo_edi_backend" />
7+
<field name="name">Demo Sale Order</field>
8+
<field name="code">demo_SaleOrder_in</field>
9+
<field name="direction">input</field>
10+
<field name="exchange_file_ext">xml</field>
11+
<field name="advanced_settings_edit">
12+
components:
13+
process:
14+
usage: input.process.sale.order
15+
env_ctx:
16+
default_price_source: 'pricelist'
17+
default_import_type: 'xml'
18+
random_key: custom
19+
</field>
20+
</record>
21+
22+
</odoo>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* Simone Orsi <simone.orsi@camptocamp.com>
2+
* Duong (Tran Quoc) <duongtq@trobz.com>
3+
* Thien (Vo Hong) <thienvh@trobz.com>

edi_sale_input_oca/readme/CREDITS.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp.
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Inbound
2+
~~~~~~~
3+
Receive sale orders from EDI channels.
4+
5+
Control sale order confirmation
6+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
8+
You can decide if the order should be confirmed by exchange type.
9+
10+
On your exchange type, go to advanced settings and add the following::
11+
12+
[...]
13+
components:
14+
process:
15+
usage: input.process.sale.order
16+
env_ctx:
17+
# Values for the wizard
18+
default_confirm_order: true
19+
default_price_source: order
20+
# Custom keys, whatever you need
21+
random_one: true
22+
23+
Note that `env_ctx` will propagate all keys to the whole env so you can use it
24+
for any kind of context related configuration. In the case of the sale order import wizard
25+
here we are just passing defaults as we could do in odoo standard.
26+
27+
TODO: shall we add an exchange type example as demo?

edi_sale_input_oca/tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_process

edi_sale_input_oca/tests/common.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2022 Camptocamp SA
2+
# @author: Simone Orsi <simahawk@gmail.com>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
from odoo import fields
6+
7+
8+
class OrderMixin(object):
9+
@classmethod
10+
def _create_sale_order(cls, **kw):
11+
"""Create a sale order
12+
13+
:return: sale order
14+
"""
15+
model = cls.env["sale.order"]
16+
vals = dict(commitment_date=fields.Date.today())
17+
vals.update(kw)
18+
so_vals = model.play_onchanges(vals, [])
19+
if "order_line" in so_vals:
20+
so_vals["order_line"] = [(0, 0, x) for x in vals["order_line"]]
21+
return model.create(so_vals)
22+
23+
@classmethod
24+
def _setup_order(cls, **kw):
25+
cls.product_a = cls.env.ref("product.product_product_4")
26+
cls.product_a.barcode = "1" * 14
27+
cls.product_b = cls.env.ref("product.product_product_4b")
28+
cls.product_b.barcode = "2" * 14
29+
cls.product_c = cls.env.ref("product.product_product_4c")
30+
cls.product_c.barcode = "3" * 14
31+
cls.product_d = cls.env.ref("product.product_product_5")
32+
cls.product_d.barcode = "4" * 14
33+
line_defaults = kw.pop("line_defaults", {})
34+
vals = {
35+
"partner_id": cls.env.ref("base.res_partner_10").id,
36+
"commitment_date": "2022-07-29",
37+
}
38+
vals.update(kw)
39+
if "client_order_ref" not in vals:
40+
vals["client_order_ref"] = "ABC123"
41+
vals["order_line"] = [
42+
{"product_id": cls.product_a.id, "product_uom_qty": 300, "edi_id": 1000},
43+
{"product_id": cls.product_b.id, "product_uom_qty": 200, "edi_id": 2000},
44+
{"product_id": cls.product_c.id, "product_uom_qty": 100, "edi_id": 3000},
45+
]
46+
if line_defaults:
47+
for line in vals["order_line"]:
48+
line.update(line_defaults)
49+
sale = cls._create_sale_order(**vals)
50+
sale.action_confirm()
51+
return sale

edi_sale_oca/tests/test_process.py edi_sale_input_oca/tests/test_process.py

+6-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
44

55
import base64
6-
import textwrap
76
from unittest import mock
87

98
from odoo.addons.component.tests.common import SavepointComponentCase
@@ -16,32 +15,17 @@ def setUpClass(cls):
1615
super().setUpClass()
1716
cls._setup_env()
1817
cls.backend = cls._get_backend()
19-
cls.exc_type = cls._create_exchange_type(
20-
name="Test SO import",
21-
code="test_so_import",
22-
direction="input",
23-
exchange_file_ext="xml",
24-
exchange_filename_pattern="{record.identifier}-{type.code}-{dt}",
25-
backend_id=cls.backend.id,
26-
# Bypass required fields with default_import_type = 'xml' in sale_order_import
27-
advanced_settings_edit=textwrap.dedent(
28-
"""
29-
components:
30-
process:
31-
usage: input.process.sale.order
32-
env_ctx:
33-
default_price_source: 'pricelist'
34-
default_import_type: 'xml'
35-
random_key: custom
36-
"""
37-
),
38-
)
18+
cls.exc_type = cls.env.ref("edi_sale_input_oca.demo_edi_exc_type_order_in")
3919
cls.record = cls.backend.create_record(
40-
"test_so_import", {"edi_exchange_state": "input_received"}
20+
cls.exc_type.code, {"edi_exchange_state": "input_received"}
4121
)
4222
cls.record._set_file_content(b"<fake><order></order></fake>")
4323
cls.wiz_model = cls.env["sale.order.import"]
4424

25+
@classmethod
26+
def _get_backend(cls):
27+
return cls.env.ref("edi_sale_oca.demo_edi_backend")
28+
4529
def test_lookup(self):
4630
comp = self.backend._get_component(self.record, "process")
4731
self.assertEqual(comp._name, "edi.input.sale.order.process")
File renamed without changes.

edi_sale_oca/README.rst

+1-122
Original file line numberDiff line numberDiff line change
@@ -1,122 +1 @@
1-
=========
2-
EDI Sales
3-
=========
4-
5-
..
6-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7-
!! This file is generated by oca-gen-addon-readme !!
8-
!! changes will be overwritten. !!
9-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:8cc00af990de28ee9679466fc10bfcfe395035c200137f800be3a5fbf69b987e
11-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12-
13-
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
14-
:target: https://odoo-community.org/page/development-status
15-
:alt: Alpha
16-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17-
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18-
:alt: License: AGPL-3
19-
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
20-
:target: https://github.com/OCA/edi/tree/14.0/edi_sale_oca
21-
:alt: OCA/edi
22-
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/edi-14-0/edi-14-0-edi_sale_oca
24-
:alt: Translate me on Weblate
25-
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=14.0
27-
:alt: Try me on Runboat
28-
29-
|badge1| |badge2| |badge3| |badge4| |badge5|
30-
31-
Inbound
32-
~~~~~~~
33-
Receive sale orders from EDI channels.
34-
35-
Control sale order confirmation
36-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37-
38-
You can decide if the order should be confirmed by exchange type.
39-
40-
On your exchange type, go to advanced settings and add the following::
41-
42-
[...]
43-
components:
44-
process:
45-
usage: input.process.sale.order
46-
env_ctx:
47-
# Values for the wizard
48-
default_confirm_order: true
49-
default_price_source: order
50-
# Custom keys, whatever you need
51-
random_one: true
52-
53-
Note that `env_ctx` will propagate all keys to the whole env so you can use it
54-
for any kind of context related configuration. In the case of the sale order import wizard
55-
here we are just passing defaults as we could do in odoo standard.
56-
57-
TODO: shall we add an exchange type example as demo?
58-
59-
.. IMPORTANT::
60-
This is an alpha version, the data model and design can change at any time without warning.
61-
Only for development or testing purpose, do not use in production.
62-
`More details on development status <https://odoo-community.org/page/development-status>`_
63-
64-
**Table of contents**
65-
66-
.. contents::
67-
:local:
68-
69-
Bug Tracker
70-
===========
71-
72-
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
73-
In case of trouble, please check there if your issue has already been reported.
74-
If you spotted it first, help us to smash it by providing a detailed and welcomed
75-
`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**>`_.
76-
77-
Do not contact contributors directly about support or help with technical issues.
78-
79-
Credits
80-
=======
81-
82-
Authors
83-
~~~~~~~
84-
85-
* Camptocamp
86-
87-
Contributors
88-
~~~~~~~~~~~~
89-
90-
* Simone Orsi <simone.orsi@camptocamp.com>
91-
* Duong (Tran Quoc) <duongtq@trobz.com>
92-
* Thien (Vo Hong) <thienvh@trobz.com>
93-
94-
Other credits
95-
~~~~~~~~~~~~~
96-
97-
The migration of this module from 14.0 to 16.0 was financially supported by Camptocamp.
98-
99-
Maintainers
100-
~~~~~~~~~~~
101-
102-
This module is maintained by the OCA.
103-
104-
.. image:: https://odoo-community.org/logo.png
105-
:alt: Odoo Community Association
106-
:target: https://odoo-community.org
107-
108-
OCA, or the Odoo Community Association, is a nonprofit organization whose
109-
mission is to support the collaborative development of Odoo features and
110-
promote its widespread use.
111-
112-
.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px
113-
:target: https://github.com/simahawk
114-
:alt: simahawk
115-
116-
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
117-
118-
|maintainer-simahawk|
119-
120-
This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/14.0/edi_sale_oca>`_ project on GitHub.
121-
122-
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1+
bot please :)

edi_sale_oca/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
from . import components
22
from . import models
3-
from . import wizard

edi_sale_oca/__manifest__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"summary": """
77
Configuration and special behaviors for EDI on sales.
88
""",
9-
"version": "14.0.1.0.0",
9+
"version": "14.0.2.0.0",
1010
"development_status": "Alpha",
1111
"license": "AGPL-3",
1212
"author": "Camptocamp,Odoo Community Association (OCA)",
@@ -15,13 +15,15 @@
1515
"depends": [
1616
"edi_oca",
1717
"edi_record_metadata_oca",
18-
"sale_order_import",
18+
"sale",
1919
],
2020
"data": [
21-
"data/job_function.xml",
2221
"views/res_partner.xml",
2322
"views/sale_order.xml",
2423
"views/edi_exchange_record.xml",
25-
"templates/exchange_chatter_msg.xml",
24+
],
25+
"demo": [
26+
"demo/edi_backend.xml",
27+
"demo/edi_exchange_type.xml",
2628
],
2729
}

edi_sale_oca/components/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
from . import process

edi_sale_oca/data/job_function.xml

-7
This file was deleted.

edi_sale_oca/demo/edi_backend.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="demo_edi_backend_type_sale" model="edi.backend.type">
4+
<field name="name">SALE DEMO</field>
5+
<field name="code">sale_demo</field>
6+
</record>
7+
<record id="demo_edi_backend" model="edi.backend">
8+
<field name="name">SALE DEMO</field>
9+
<field name="backend_type_id" ref="demo_edi_backend_type_sale" />
10+
</record>
11+
</odoo>

0 commit comments

Comments
 (0)