diff --git a/timesheet_exception/demo/timesheet_exception_demo.xml b/timesheet_exception/demo/timesheet_exception_demo.xml
index a51ee7a8..cce8b928 100644
--- a/timesheet_exception/demo/timesheet_exception_demo.xml
+++ b/timesheet_exception/demo/timesheet_exception_demo.xml
@@ -6,8 +6,8 @@
Unit amount over 8 hrs
50
account.analytic.line
- if timesheet.unit_amount > 8: failed=True
-
+ if self.unit_amount > 8: failed=True
+
@@ -15,8 +15,8 @@
SO delivered qty plus unit amount exceeds ordered qty
50
account.analytic.line
- if timesheet.so_line.product_template_id.service_policy == 'ordered_timesheet' and timesheet.so_line.qty_delivered + timesheet.unit_amount > timesheet.so_line.product_uom_qty: failed=True
-
+ if self.so_line.product_template_id.service_policy == 'ordered_timesheet' and self.so_line.qty_delivered + self.unit_amount > self.so_line.product_uom_qty: failed=True
+
diff --git a/timesheet_exception/models/analytic.py b/timesheet_exception/models/analytic.py
index 65baf1e7..fe7e226a 100644
--- a/timesheet_exception/models/analytic.py
+++ b/timesheet_exception/models/analytic.py
@@ -30,20 +30,14 @@ class AnalyticLine(models.Model):
res.detect_exceptions()
return res
- @api.model
- def _exception_rule_eval_context(self, rec):
- res = super(AnalyticLine, self)._exception_rule_eval_context(rec)
- res['timesheet'] = rec
- return res
-
@api.model
def _reverse_field(self):
return 'timesheet_ids'
- def write(self, vals):
+ def write(self, vals):
if not vals.get('ignore_exception'):
for timesheet in self:
- if timesheet.detect_exceptions():
+ if timesheet.detect_exceptions() and 'stage_id' in vals:
return self._popup_exceptions()
return super().write(vals)
diff --git a/timesheet_exception/wizard/timesheet_exception_confirm.py b/timesheet_exception/wizard/timesheet_exception_confirm.py
index 8b0a64af..9fca68b7 100644
--- a/timesheet_exception/wizard/timesheet_exception_confirm.py
+++ b/timesheet_exception/wizard/timesheet_exception_confirm.py
@@ -16,7 +16,7 @@ class TimesheetExceptionConfirm(models.TransientModel):
self.related_model_id.ignore_exception = True
res = super().action_confirm()
if self.ignore:
- return True
+ return self.action_validate_timesheet()
else:
return res