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="description">Unit amount over 8 hrs</field>
|
||||||
<field name="sequence">50</field>
|
<field name="sequence">50</field>
|
||||||
<field name="model">account.analytic.line</field>
|
<field name="model">account.analytic.line</field>
|
||||||
<field name="code">if timesheet.unit_amount > 8: failed=True</field>
|
<field name="code">if self.unit_amount > 8: failed=True</field>
|
||||||
<field name="active" eval="False"/>
|
<field name="active" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="except_unit_amount_over_ordered_quantity" model="exception.rule">
|
<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="description">SO delivered qty plus unit amount exceeds ordered qty</field>
|
||||||
<field name="sequence">50</field>
|
<field name="sequence">50</field>
|
||||||
<field name="model">account.analytic.line</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="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="False"/>
|
<field name="active" eval="True"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -30,20 +30,14 @@ class AnalyticLine(models.Model):
|
|||||||
res.detect_exceptions()
|
res.detect_exceptions()
|
||||||
return res
|
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
|
@api.model
|
||||||
def _reverse_field(self):
|
def _reverse_field(self):
|
||||||
return 'timesheet_ids'
|
return 'timesheet_ids'
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
if not vals.get('ignore_exception'):
|
if not vals.get('ignore_exception'):
|
||||||
for timesheet in self:
|
for timesheet in self:
|
||||||
if timesheet.detect_exceptions():
|
if timesheet.detect_exceptions() and 'stage_id' in vals:
|
||||||
return self._popup_exceptions()
|
return self._popup_exceptions()
|
||||||
return super().write(vals)
|
return super().write(vals)
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class TimesheetExceptionConfirm(models.TransientModel):
|
|||||||
self.related_model_id.ignore_exception = True
|
self.related_model_id.ignore_exception = True
|
||||||
res = super().action_confirm()
|
res = super().action_confirm()
|
||||||
if self.ignore:
|
if self.ignore:
|
||||||
return True
|
return self.action_validate_timesheet()
|
||||||
else:
|
else:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user