Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4553 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

Have to get the 'is_validating_to' from res.

Like

if 'is_validating_to' in vals and res.is_validating_to:


Kind Regards,


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
gru 23
12677
3
lip 22
23023
4
sie 21
15938
2
cze 21
18467
0
wrz 20
3693