From c0ec8ec69f088055ba2619010bde5cd838c079ae Mon Sep 17 00:00:00 2001 From: percyhibou Date: Thu, 6 Oct 2022 18:17:23 +0000 Subject: [PATCH] [FIX] timesheet_exception: modify code to check "validated" is set in "vals" H11047 --- timesheet_exception/demo/timesheet_exception_demo.xml | 4 ++-- timesheet_exception/models/analytic.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/timesheet_exception/demo/timesheet_exception_demo.xml b/timesheet_exception/demo/timesheet_exception_demo.xml index cce8b928..f8dd3ce9 100644 --- a/timesheet_exception/demo/timesheet_exception_demo.xml +++ b/timesheet_exception/demo/timesheet_exception_demo.xml @@ -6,7 +6,7 @@ Unit amount over 8 hrs 50 account.analytic.line - if self.unit_amount > 8: failed=True + failed = self._context.get("newVals", {}).get("validated", False) == True and self.unit_amount > 8 @@ -15,7 +15,7 @@ SO delivered qty plus unit amount exceeds ordered qty 50 account.analytic.line - 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 + failed = self._context.get("newVals", {}).get("validated", False) == True and (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) diff --git a/timesheet_exception/models/analytic.py b/timesheet_exception/models/analytic.py index fe7e226a..20be8b00 100644 --- a/timesheet_exception/models/analytic.py +++ b/timesheet_exception/models/analytic.py @@ -34,10 +34,10 @@ class AnalyticLine(models.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() and 'stage_id' in vals: + for timesheet in self: + if timesheet.with_context(newVals=vals).detect_exceptions(): return self._popup_exceptions() return super().write(vals)