跳至内容
菜单
此问题已终结
1 回复
4563 查看

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,


形象
丢弃
相关帖文 回复 查看 活动
2
12月 23
12690
3
7月 22
23039
4
8月 21
15967
2
6月 21
18474
0
9月 20
3706