diff --git a/sale_exception/models/sale_order_line.py b/sale_exception/models/sale_order_line.py
index c786c4940b8..e36cc8ca124 100644
--- a/sale_exception/models/sale_order_line.py
+++ b/sale_exception/models/sale_order_line.py
@@ -19,6 +19,14 @@ class SaleOrderLine(models.Model):
ignore_exception = fields.Boolean(
related="order_id.ignore_exception", store=True, string="Ignore Exceptions"
)
+ is_exception_danger = fields.Boolean(compute="_compute_is_exception_danger")
+
+ @api.depends("exception_ids", "ignore_exception")
+ def _compute_is_exception_danger(self):
+ for rec in self:
+ rec.is_exception_danger = (
+ len(rec.exception_ids) > 0 and not rec.ignore_exception
+ )
@api.depends("exception_ids", "ignore_exception")
def _compute_exceptions_summary(self):
diff --git a/sale_exception/tests/test_multi_records.py b/sale_exception/tests/test_multi_records.py
index d23713c34fd..377fb0b5f4d 100644
--- a/sale_exception/tests/test_multi_records.py
+++ b/sale_exception/tests/test_multi_records.py
@@ -71,10 +71,12 @@ def test_sale_order_exception(self):
)
orders = so1 + so2 + so3
+ # ensure init state
for order in orders:
- # ensure init state
self.assertTrue(order.state == "draft")
self.assertTrue(len(order.exception_ids) == 0)
+ self.assertFalse(so1.order_line[0].is_exception_danger)
+ self.assertFalse(so3.order_line[0].is_exception_danger)
self.env["sale.order"].test_all_draft_orders()
@@ -82,6 +84,7 @@ def test_sale_order_exception(self):
self.assertTrue(so1.state == "draft")
self.assertTrue(len(so1.exception_ids) == 0)
+ self.assertFalse(so1.order_line[0].is_exception_danger)
self.assertTrue(so2.state == "draft")
self.assertTrue(exception_no_sol in so2.exception_ids)
@@ -97,6 +100,7 @@ def test_sale_order_exception(self):
""
),
)
+ self.assertTrue(so3.order_line[0].is_exception_danger)
# test return value of detect_exception()
diff --git a/sale_exception/views/sale_view.xml b/sale_exception/views/sale_view.xml
index fce672e5a50..fa54a925682 100644
--- a/sale_exception/views/sale_view.xml
+++ b/sale_exception/views/sale_view.xml
@@ -65,13 +65,10 @@
-
-
+
- not ignore_exception and exception_ids
+ is_exception_danger