mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] timesheet_exception: narrow down when to _popup_exceptions() on write() calls
H11047
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
<field name="description">Unit amount over 8 hrs</field>
|
||||
<field name="sequence">50</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="code">if timesheet.unit_amount > 8: failed=True</field>
|
||||
<field name="active" eval="False"/>
|
||||
<field name="code">if self.unit_amount > 8: failed=True</field>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record id="except_unit_amount_over_ordered_quantity" model="exception.rule">
|
||||
@@ -15,8 +15,8 @@
|
||||
<field name="description">SO delivered qty plus unit amount exceeds ordered qty</field>
|
||||
<field name="sequence">50</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="code">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</field>
|
||||
<field name="active" eval="False"/>
|
||||
<field name="code">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</field>
|
||||
<field name="active" eval="True"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -30,12 +30,6 @@ 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'
|
||||
@@ -43,7 +37,7 @@ class AnalyticLine(models.Model):
|
||||
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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user