Hi Guys,Is there any way to calculate the total outstanding credits of a customer,I have a Balance smart button I have to compute the total outstanding credits of a particular customer
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
1601
Views
Hi,
Use this code,
account_types = []
receivable_type = self.env.ref('account.data_account_type_receivable').id
payable_type = self.env.ref('account.data_account_type_payable').id
account_types.extend([receivable_type, payable_type])
domain = [('partner_id', '=', self.id), ('amount_residual', '!=', 0),
('account_id.user_type_id', 'in', account_types)]
domain += [('move_id.state', '=', 'posted')]
customer_balance = sum([x.amount_residual for x in self.env['account.move.line'].search(domain)])
Thanks
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up