Skip to Content
Menu
This question has been flagged
1 Reply
3439 Views

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()

Avatar
Discard
Best Answer

Have to get the 'is_validating_to' from res.

Like

if 'is_validating_to' in vals and res.is_validating_to:


Kind Regards,


Avatar
Discard
Related Posts Replies Views Activity
2
Dec 23
11087
3
Jul 22
20956
4
Aug 21
14759
2
Jun 21
16961
0
Sep 20
2622