Skip to Content
Menu
This question has been flagged
1 Reply
2264 Views
@api.model
def write(self, values):
invoice_paid_amount = 0
res = super(AccountMove, self).write(values)
if 'state' in values and values['state'] == 'posted':
invoice_id = self.env['account.move'].search([('name', '=', self.ref)])
if invoice_id.type == 'out_invoice':
invoice_paid_amount += abs(invoice_id.amount_total - invoice_id.amount_residual)
print("invoice_paid_amount", invoice_paid_amount)


else:
print("error")
return res
Avatar
Discard
Best Answer
invoice_paid_amount = 0
for line in invoice_id._get_reconciled_info_JSON_values():
invoice_paid_amount += line['amount']
print("invoice_paid_amount", invoice_paid_amount)
Avatar
Discard

Useful! Thanks for sharing.