Skip to content
Snippets Groups Projects
Unverified Commit f5b00c11 authored by Olivier Dony's avatar Olivier Dony
Browse files

[FIX] account_payment: properly compute destination account without partner

When the `partner_id` is not set (it is not required at the model
level), we can still compute the default destination account based on
the company chart of account configuration.

This is necessary to allow creating "customer" or "supplier" payments without
selecting a specific partner.
parent 9a9da576
No related branches found
No related tags found
No related merge requests found
......@@ -361,6 +361,12 @@ class account_payment(models.Model):
self.destination_account_id = self.partner_id.property_account_receivable_id.id
else:
self.destination_account_id = self.partner_id.property_account_payable_id.id
elif self.partner_type == 'customer':
default_account = self.env['ir.property'].get('property_account_receivable_id', 'res.partner')
self.destination_account_id = default_account.id
elif self.partner_type == 'supplier':
default_account = self.env['ir.property'].get('property_account_payable_id', 'res.partner')
self.destination_account_id = default_account.id
@api.onchange('partner_type')
def _onchange_partner_type(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment