forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] purchase_exception: Migration to 13.0
- Loading branch information
Showing
11 changed files
with
15 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ Purchase Exception | |
:target: https://runbot.odoo-community.org/runbot/142/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows you attach several customizable exceptions to your | ||
purchase order in a way that you can filter orders by exceptions type and fix them. | ||
|
@@ -67,6 +67,7 @@ Contributors | |
|
||
* Mourad EL HADJ MIMOUNE <[email protected]> | ||
* Sudhir Arya <[email protected]> | ||
* Darius Martinkus <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
purchase_exception/migrations/12.0.1.0.1/noupdate_changes.xml
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
purchase_exception/migrations/12.0.1.0.1/post-migration.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Copyright 2017 Akretion (http://www.akretion.com) | ||
# Copyright 2020 Camptocamp SA | ||
# Mourad EL HADJ MIMOUNE <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
# Copyright 2017 Akretion (http://www.akretion.com) | ||
# Copyright 2020 Camptocamp SA | ||
# Mourad EL HADJ MIMOUNE <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
|
||
from odoo import api, models | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PurchaseOrder(models.Model): | ||
_inherit = ["purchase.order", "base.exception"] | ||
|
@@ -20,22 +17,6 @@ def test_all_draft_orders(self): | |
order_set.detect_exceptions() | ||
return True | ||
|
||
@api.model | ||
def _exception_rule_eval_context(self, rec): | ||
# TODO remove in v13 | ||
# We keep this only for backward compatibility | ||
res = super()._exception_rule_eval_context(rec) | ||
if res.get("purchase"): | ||
logger.warning( | ||
""" | ||
For a full compatibility with future versions of this module, | ||
please use 'self' instead of 'purchase' in your | ||
custom exceptions rules. | ||
""" | ||
) | ||
res["purchase"] = rec | ||
return res | ||
|
||
@api.model | ||
def _reverse_field(self): | ||
return "purchase_ids" | ||
|
@@ -57,15 +38,13 @@ def onchange_ignore_exception(self): | |
if self.state == "purchase": | ||
self.ignore_exception = False | ||
|
||
@api.multi | ||
def button_confirm(self): | ||
if self.detect_exceptions() and not self.ignore_exception: | ||
return self._popup_exceptions() | ||
return super(PurchaseOrder, self).button_confirm() | ||
return super().button_confirm() | ||
|
||
@api.multi | ||
def button_draft(self): | ||
res = super(PurchaseOrder, self).button_draft() | ||
res = super().button_draft() | ||
for order in self: | ||
order.exception_ids = False | ||
order.main_exception_id = False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
# Copyright 2017 Akretion (http://www.akretion.com) | ||
# Copyright 2020 Camptocamp SA | ||
# Mourad EL HADJ MIMOUNE <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
|
||
from odoo import api, fields, models | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_inherit = ["purchase.order.line", "base.exception.method"] | ||
|
@@ -17,33 +14,13 @@ class PurchaseOrderLine(models.Model): | |
related="order_id.ignore_exception", store=True, string="Ignore Exceptions" | ||
) | ||
|
||
@api.multi | ||
def _get_main_records(self): | ||
return self.mapped("order_id") | ||
|
||
@api.model | ||
def _reverse_field(self): | ||
return "purchase_ids" | ||
|
||
@api.multi | ||
def _detect_exceptions(self, rule): | ||
records = super()._detect_exceptions(rule) | ||
return records.mapped("order_id") | ||
|
||
@api.model | ||
def _exception_rule_eval_context(self, rec): | ||
# TODO remove in v13 | ||
# We keep this only for backward compatibility, because some existing | ||
# rules may use the variable "purchase_line". But we should remove this | ||
# code during v13 migration. | ||
res = super()._exception_rule_eval_context(rec) | ||
if res.get("purchase_line"): | ||
logger.warning( | ||
""" | ||
For a full compatibility with future versions of this module, | ||
please use 'self' instead of 'purchase_line' in your | ||
custom exceptions rules. | ||
""" | ||
) | ||
res["purchase_line"] = rec | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Copyright 2017 Akretion (http://www.akretion.com) | ||
# Copyright 2020 Camptocamp SA | ||
# Mourad EL HADJ MIMOUNE <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from datetime import datetime | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
# Copyright 2017 Akretion (http://www.akretion.com) | ||
# Copyright 2020 Camptocamp SA | ||
# Mourad EL HADJ MIMOUNE <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, fields, models | ||
from odoo import fields, models | ||
|
||
|
||
class PurchaseExceptionConfirm(models.TransientModel): | ||
_name = "purchase.exception.confirm" | ||
_description = "Purchase exception wizard" | ||
_inherit = ["exception.rule.confirm"] | ||
|
||
related_model_id = fields.Many2one("purchase.order", "Purchase") | ||
|
||
@api.multi | ||
def action_confirm(self): | ||
self.ensure_one() | ||
if self.ignore: | ||
self.related_model_id.button_draft() | ||
self.related_model_id.ignore_exception = True | ||
self.related_model_id.button_confirm() | ||
return super(PurchaseExceptionConfirm, self).action_confirm() | ||
return super().action_confirm() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters