I have a method make_sale_order(): where can change state of model "sale.order" from 'technical_offer' to 'draft' and set 'is_validating_to' True
@api.multi
def make_sale_order(self):
self._model.write(self._cr, SUPERUSER_ID, self.id, {'is_validating_to': True, 'state': 'draft'})
for line in self.order_line:
line.state = 'draft'
return True
in my method write i set this code:
@api.multi def write(self, vals):
res = super(SaleOrder, self).write(vals)
if 'is_validating_to' in vals and vals['is_validating_to'] is True:
return res
else:
for rec in self.order_line:
if self.margin_percent < self.order_min_margin and self.order_line and self.state in ['draft', 'draft_to_validate']:
raise except_orm(_('Margin error!'), _("margin cannot be lower than '%s'!") % str(self.order_min_margin,))
return res
i have a problem in the condition " if 'is_validating_to' in vals and vals['is_validating_to'] is True " where vals not updated to have 'is_validating_to' as a changed field, so it passed to the raise except_orm()