Skip to content

Commit b4b1496

Browse files
author
phucph
committed
[MIG] edi_purchase_oca: Migration to 18.0
1 parent 888c9c7 commit b4b1496

File tree

21 files changed

+57
-150
lines changed

21 files changed

+57
-150
lines changed

edi_purchase_oca/README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ Authors
6565
-------
6666

6767
* ForgeFlow
68+
* Camptocamp
6869

6970
Contributors
7071
------------
7172

72-
- Lois Rilo <lois.rilo@forgeflow.com>
73+
- Lois Rilo lois.rilo@forgeflow.com
74+
- Simone Orsi simone.orsi@camptocamp.com
75+
76+
- Phan Hong Phuc <phucph@trobz.com>
7377

7478
Maintainers
7579
-----------

edi_purchase_oca/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "EDI Purchase",
66
"summary": """
77
Define EDI Configuration for Purchase Orders""",
8-
"version": "17.0.1.0.0",
8+
"version": "18.0.1.0.0",
99
"license": "LGPL-3",
1010
"author": "ForgeFlow, Camptocamp, Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/edi-framework",
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<odoo>
3-
<!-- Generic state change -->
4-
<record
3+
<!-- Generic state change -->
4+
<record
55
id="edi_conf_trigger_purchase_order_state_change"
66
model="edi.configuration.trigger"
77
>
8-
<field name="name">On PO state change</field>
9-
<field name="code">on_edi_purchase_order_state_change</field>
10-
<field name="description">Trigger when a purchase order state changes</field>
11-
<field name="model_id" ref="purchase.model_purchase_order" />
12-
</record>
8+
<field name="name">On PO state change</field>
9+
<field name="code">on_edi_purchase_order_state_change</field>
10+
<field name="description">Trigger when a purchase order state changes</field>
11+
<field name="model_id" ref="purchase.model_purchase_order" />
12+
</record>
1313
</odoo>
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<odoo>
3-
43
<record id="demo_edi_exc_type_order_out" model="edi.exchange.type">
54
<field name="backend_type_id" ref="demo_edi_backend_type_purchase" />
65
<field name="backend_id" ref="demo_edi_backend" />
@@ -10,5 +9,4 @@
109
<field name="exchange_filename_pattern">{record_name}-{type.code}-{dt}</field>
1110
<field name="exchange_file_ext">xml</field>
1211
</record>
13-
1412
</odoo>
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
22
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
33

4+
from contextlib import contextmanager
5+
46
from odoo import models
57

68

@@ -12,17 +14,19 @@ class PurchaseOrder(models.Model):
1214
]
1315

1416
def button_confirm(self):
15-
res = super().button_confirm()
16-
# DEPRECATED: rely on `on_edi_purchase_order_state_change`
17-
# provided automatically by edi.consumer.mixin
18-
if self: # TODO: is this check necessary?
19-
self._event("on_button_confirm_purchase_order").notify(self)
20-
return res
17+
with self._edi_purchase_order_state_change_trigger():
18+
result = super().button_confirm()
19+
return result
2120

2221
def button_cancel(self):
23-
result = super().button_cancel()
24-
# DEPRECATED: rely on `on_edi_purchase_order_state_change`
25-
# provided automatically by edi.consumer.mixin
26-
if self:
27-
self._event("on_button_cancel_purchase_order").notify(self)
22+
with self._edi_purchase_order_state_change_trigger():
23+
result = super().button_cancel()
2824
return result
25+
26+
@contextmanager
27+
def _edi_purchase_order_state_change_trigger(self):
28+
for order in self:
29+
order._event("on_edi_purchase_order_state_change").notify(
30+
order, state=order.state
31+
)
32+
yield
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
- Lois Rilo \<<lois.rilo@forgeflow.com>\>
1+
* Lois Rilo <lois.rilo@forgeflow.com>
2+
* Simone Orsi <simone.orsi@camptocamp.com>
3+
- Phan Hong Phuc \<<phucph@trobz.com>\>

edi_purchase_oca/readme/CONTRIBUTORS.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

edi_purchase_oca/readme/DESCRIPTION.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

edi_purchase_oca/static/description/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,15 @@ <h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
408408
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
409409
<ul class="simple">
410410
<li>ForgeFlow</li>
411+
<li>Camptocamp</li>
411412
</ul>
412413
</div>
413414
<div class="section" id="contributors">
414415
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
415416
<ul class="simple">
416-
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
417+
<li>Lois Rilo <a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a></li>
418+
<li>Simone Orsi <a class="reference external" href="mailto:simone.orsi&#64;camptocamp.com">simone.orsi&#64;camptocamp.com</a></li>
419+
<li>Phan Hong Phuc &lt;<a class="reference external" href="mailto:phucph&#64;trobz.com">phucph&#64;trobz.com</a>&gt;</li>
417420
</ul>
418421
</div>
419422
<div class="section" id="maintainers">

edi_purchase_oca/tests/test_edi_conf.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from unittest import mock
55

6+
from odoo import Command
7+
68
from odoo.addons.edi_oca.tests.common import EDIBackendCommonComponentTestCase
79

810

@@ -21,24 +23,24 @@ def setUpClass(cls):
2123
cls.edi_conf = cls.env.ref("edi_purchase_oca.demo_edi_configuration_confirmed")
2224
cls.partner.edi_purchase_conf_ids = cls.edi_conf
2325

24-
@mock.patch("odoo.addons.edi_oca.models.edi_backend.EDIBackend._validate_data")
25-
@mock.patch("odoo.addons.edi_oca.models.edi_backend.EDIBackend._exchange_generate")
26-
@mock.patch("odoo.addons.edi_oca.models.edi_backend.EDIBackend._exchange_send")
26+
@mock.patch("odoo.addons.edi_core_oca.models.edi_backend.EDIBackend._validate_data")
27+
@mock.patch(
28+
"odoo.addons.edi_core_oca.models.edi_backend.EDIBackend._exchange_generate"
29+
)
30+
@mock.patch("odoo.addons.edi_core_oca.models.edi_backend.EDIBackend._exchange_send")
2731
def test_order_confirm(self, mock_send, mock_generate, mock_validate):
2832
mock_generate.return_value = "TEST PO OUT"
2933
order = self.purchase_order.create(
3034
{
3135
"partner_id": self.partner.id,
3236
"order_line": [
33-
(
34-
0,
35-
0,
37+
Command.create(
3638
{
3739
"product_id": self.product.id,
3840
"product_qty": 10,
3941
"price_unit": 100.0,
40-
},
41-
)
42+
}
43+
),
4244
],
4345
}
4446
)

0 commit comments

Comments
 (0)