Skip to content

Commit

Permalink
[FIX] account_payment: properly compute destination account without p…
Browse files Browse the repository at this point in the history
…artner

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.
  • Loading branch information
odony committed Apr 6, 2018
1 parent 9a9da57 commit f5b00c1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addons/account/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ def _compute_destination_account_id(self):
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):
Expand Down

0 comments on commit f5b00c1

Please sign in to comment.