Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
4556 Переглядів

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

Аватар
Відмінити
Найкраща відповідь

Have to get the 'is_validating_to' from res.

Like

if 'is_validating_to' in vals and res.is_validating_to:


Kind Regards,


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
груд. 23
12679
3
лип. 22
23024
4
серп. 21
15946
2
черв. 21
18468
0
вер. 20
3697