Skip to Content
Menu
This question has been flagged
1081 Views

I  have a read-only boolean "Credit Limit Block" on the sales.order which is set to  true when credit limit is exceeded .
I will reopen the sales order when the payments are made and credit limit is not exceeded any more .

I override  "_write" function in "account.invoice" model  , is what i did right in your own eyes ?

 

class AccountInvoice(models.Model):
_name = "account.invoice"
_inherit = "account.invoice"

@api.multi
def _write(self, vals):
res = super(AccountInvoice, self)._write(vals)
if vals and (vals.get('state') == 'paid' or vals.get('residual')):
blocked_sale_order = self.env['sale.order'].search([('partner_id', '=', self.partner_id.id),
('credit_limit_block', '=', True)])
for status in blocked_sale_order:
status.check_limit()
break
return
res



Avatar
Discard