Dejan Dakovic
Dejan Dakovic

Reputation: 155

Odoo 10 how to calculate the total debt of partner

I would like to calculate the total debt of partner_id, with all his debit on every his invoice

as an example:

In Accounting\Customer Invoices I have a

enter image description here

when I click on bbb opens

enter image description here

when I click on the report, in my case Automatski racun

enter image description here

I want to enter in the field Vaš ukupan dug the total debt of all accounts that bbb has

And can you tell me how to iterate over all partner_id eg. in the Journal Items Because I tried this way to get a total of bbb debt, but I did not know how to iterate

If I'm not clear enough or you need more information, please let me know

Upvotes: 0

Views: 178

Answers (1)

Pablo Escobar
Pablo Escobar

Reputation: 685

Here it is the code.

@api.onchange('partner_id')
    def set_customer_credit(self):
        self.custom_field = self.partner_id.credit

Upvotes: 1

Related Questions