Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion purchase_exception/models/purchase.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ def purchase_check_exception(self):
if orders:
orders._check_exception()

def _must_popup_exception(self):
return True

def button_confirm(self):
if self.detect_exceptions() and not self.ignore_exception:
return self._popup_exceptions()
return self.action_popup_exceptions()
return super().button_confirm()

def button_draft(self):
Expand Down
4 changes: 4 additions & 0 deletions purchase_exception/models/purchase_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ def _reverse_field(self):
def _detect_exceptions(self, rule):
records = super()._detect_exceptions(rule)
return records.mapped("order_id")

def _detect_exception_get_exc_class_values(self):
res = super()._detect_exception_get_exc_class_values()
return dict(res, target_model="purchase.order")
7 changes: 7 additions & 0 deletions purchase_exception/tests/test_purchase_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT

from odoo.addons.base.tests.common import BaseCommon
from odoo.addons.base_exception.tests.common import (
patch_base_exception_method_env,
swallow_base_exception_error,
)


class TestPurchaseException(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, test_base_exception=True))
# Useful models
cls.PurchaseOrder = cls.env["purchase.order"]
cls.PurchaseOrderLine = cls.env["purchase.order.line"]
Expand Down Expand Up @@ -71,6 +76,8 @@ def setUpClass(cls):
],
}

@patch_base_exception_method_env
@swallow_base_exception_error
def test_purchase_order_exception(self):
self.exception_noemail.active = True
self.exception_qtycheck.active = True
Expand Down
5 changes: 4 additions & 1 deletion purchase_request_exception/models/purchase_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def onchange_ignore_exception(self):
if self.state == "to_approve":
self.ignore_exception = False

def _must_popup_exception(self):
return True

def button_to_approve(self):
if self.detect_exceptions() and not self.ignore_exception:
return self._popup_exceptions()
return
return super().button_to_approve()

def button_draft(self):
Expand Down
4 changes: 4 additions & 0 deletions purchase_request_exception/models/purchase_request_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ def _reverse_field(self):
def _detect_exceptions(self, rule):
records = super()._detect_exceptions(rule)
return records.mapped("request_id")

def _detect_exception_get_exc_class_values(self):
res = super()._detect_exception_get_exc_class_values()
return dict(res, target_model="purchase.request")
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
from odoo.tests.common import TransactionCase
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT

from odoo.addons.base_exception.tests.common import (
patch_base_exception_method_env,
swallow_base_exception_error,
)


class TestPurchaseRequestException(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

cls.env = cls.env(context=dict(cls.env.context, test_base_exception=True))
# Useful models
cls.PurchaseRequest = cls.env["purchase.request"]
cls.PurchaseRequestLine = cls.env["purchase.request.line"]
Expand Down Expand Up @@ -49,6 +54,8 @@ def setUpClass(cls):
],
}

@patch_base_exception_method_env
@swallow_base_exception_error
def test_purchase_request_exception(self):
self.exception_noapprover.active = True
self.exception_qtycheck.active = True
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
odoo_test_helper
odoo-addon-base_exception @ git+https://github.com/OCA/server-tools.git@refs/pull/3590/head#subdirectory=base_exception
Loading