Skip to content

Commit cd851ed

Browse files
teewuxkittiu
authored andcommitted
[MIG] purchase_exception: Migration to 13.0
1 parent ddd5031 commit cd851ed

11 files changed

+15
-82
lines changed

purchase_exception/README.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Purchase Exception
2323
:target: https://runbot.odoo-community.org/runbot/142/12.0
2424
:alt: Try me on Runbot
2525

26-
|badge1| |badge2| |badge3| |badge4| |badge5|
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
2727

2828
This module allows you attach several customizable exceptions to your
2929
purchase order in a way that you can filter orders by exceptions type and fix them.
@@ -67,6 +67,7 @@ Contributors
6767

6868
* Mourad EL HADJ MIMOUNE <[email protected]>
6969
* Sudhir Arya <[email protected]>
70+
* Darius Martinkus <[email protected]>
7071

7172
Maintainers
7273
~~~~~~~~~~~

purchase_exception/__manifest__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
{
66
"name": "Purchase Exception",
77
"summary": "Custom exceptions on purchase order",
8-
"version": "12.0.1.1.0",
8+
"version": "13.0.1.0.0",
99
"category": "Generic Modules/Purchase",
1010
"author": "Akretion, Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/purchase-workflow",
12-
"depends": ["purchase", "base_exception",],
12+
"depends": ["purchase", "base_exception"],
1313
"license": "AGPL-3",
1414
"data": [
1515
"data/purchase_exception_data.xml",

purchase_exception/migrations/12.0.1.0.1/noupdate_changes.xml

-16
This file was deleted.

purchase_exception/migrations/12.0.1.0.1/post-migration.py

-10
This file was deleted.

purchase_exception/models/exception_rule.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2017 Akretion (http://www.akretion.com)
2+
# Copyright 2020 Camptocamp SA
23
# Mourad EL HADJ MIMOUNE <[email protected]>
34
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
45

purchase_exception/models/purchase.py

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# Copyright 2017 Akretion (http://www.akretion.com)
2+
# Copyright 2020 Camptocamp SA
23
# Mourad EL HADJ MIMOUNE <[email protected]>
34
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
45

5-
import logging
6-
76
from odoo import api, models
87

9-
logger = logging.getLogger(__name__)
10-
118

129
class PurchaseOrder(models.Model):
1310
_inherit = ["purchase.order", "base.exception"]
@@ -20,22 +17,6 @@ def test_all_draft_orders(self):
2017
order_set.detect_exceptions()
2118
return True
2219

23-
@api.model
24-
def _exception_rule_eval_context(self, rec):
25-
# TODO remove in v13
26-
# We keep this only for backward compatibility
27-
res = super()._exception_rule_eval_context(rec)
28-
if res.get("purchase"):
29-
logger.warning(
30-
"""
31-
For a full compatibility with future versions of this module,
32-
please use 'self' instead of 'purchase' in your
33-
custom exceptions rules.
34-
"""
35-
)
36-
res["purchase"] = rec
37-
return res
38-
3920
@api.model
4021
def _reverse_field(self):
4122
return "purchase_ids"
@@ -57,15 +38,13 @@ def onchange_ignore_exception(self):
5738
if self.state == "purchase":
5839
self.ignore_exception = False
5940

60-
@api.multi
6141
def button_confirm(self):
6242
if self.detect_exceptions() and not self.ignore_exception:
6343
return self._popup_exceptions()
64-
return super(PurchaseOrder, self).button_confirm()
44+
return super().button_confirm()
6545

66-
@api.multi
6746
def button_draft(self):
68-
res = super(PurchaseOrder, self).button_draft()
47+
res = super().button_draft()
6948
for order in self:
7049
order.exception_ids = False
7150
order.main_exception_id = False
+1-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# Copyright 2017 Akretion (http://www.akretion.com)
2+
# Copyright 2020 Camptocamp SA
23
# Mourad EL HADJ MIMOUNE <[email protected]>
34
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
45

5-
import logging
6-
76
from odoo import api, fields, models
87

9-
logger = logging.getLogger(__name__)
10-
118

129
class PurchaseOrderLine(models.Model):
1310
_inherit = ["purchase.order.line", "base.exception.method"]
@@ -17,33 +14,13 @@ class PurchaseOrderLine(models.Model):
1714
related="order_id.ignore_exception", store=True, string="Ignore Exceptions"
1815
)
1916

20-
@api.multi
2117
def _get_main_records(self):
2218
return self.mapped("order_id")
2319

2420
@api.model
2521
def _reverse_field(self):
2622
return "purchase_ids"
2723

28-
@api.multi
2924
def _detect_exceptions(self, rule):
3025
records = super()._detect_exceptions(rule)
3126
return records.mapped("order_id")
32-
33-
@api.model
34-
def _exception_rule_eval_context(self, rec):
35-
# TODO remove in v13
36-
# We keep this only for backward compatibility, because some existing
37-
# rules may use the variable "purchase_line". But we should remove this
38-
# code during v13 migration.
39-
res = super()._exception_rule_eval_context(rec)
40-
if res.get("purchase_line"):
41-
logger.warning(
42-
"""
43-
For a full compatibility with future versions of this module,
44-
please use 'self' instead of 'purchase_line' in your
45-
custom exceptions rules.
46-
"""
47-
)
48-
res["purchase_line"] = rec
49-
return res

purchase_exception/tests/test_purchase_exception.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2017 Akretion (http://www.akretion.com)
2+
# Copyright 2020 Camptocamp SA
23
# Mourad EL HADJ MIMOUNE <[email protected]>
34
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
45
from datetime import datetime

purchase_exception/views/purchase_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<field name="model">purchase.order</field>
7272
<field name="inherit_id" ref="purchase.view_purchase_order_filter" />
7373
<field name="arch" type="xml">
74-
<filter name="activities_my" position="after">
74+
<filter name="activities_exception" position="after">
7575
<separator orientation="vertical" />
7676
<filter
7777
icon="fa-exclamation-circle"
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# Copyright 2017 Akretion (http://www.akretion.com)
2+
# Copyright 2020 Camptocamp SA
23
# Mourad EL HADJ MIMOUNE <[email protected]>
34
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
45

5-
from odoo import api, fields, models
6+
from odoo import fields, models
67

78

89
class PurchaseExceptionConfirm(models.TransientModel):
910
_name = "purchase.exception.confirm"
11+
_description = "Purchase exception wizard"
1012
_inherit = ["exception.rule.confirm"]
1113

1214
related_model_id = fields.Many2one("purchase.order", "Purchase")
1315

14-
@api.multi
1516
def action_confirm(self):
1617
self.ensure_one()
1718
if self.ignore:
1819
self.related_model_id.button_draft()
1920
self.related_model_id.ignore_exception = True
2021
self.related_model_id.button_confirm()
21-
return super(PurchaseExceptionConfirm, self).action_confirm()
22+
return super().action_confirm()

purchase_exception/wizard/purchase_exception_confirm_view.xml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<field name="name">Outstanding exceptions to manage</field>
55
<field name="type">ir.actions.act_window</field>
66
<field name="res_model">purchase.exception.confirm</field>
7-
<field name="view_type">form</field>
87
<field name="view_mode">form</field>
98
<field name="view_id" ref="base_exception.view_exception_rule_confirm" />
109
<field name="target">new</field>

0 commit comments

Comments
 (0)