Skip to content

Commit

Permalink
[FIX] account_voucher: right domain on payment method
Browse files Browse the repository at this point in the history
When creating a receipt with immediate payment:
Before this commit, the field payment method displayed all the journals bank or cash

After this commit, only journals made for receiving/sending payment (in function of the type of receipt)
are displayed

OPW 1819672

closes odoo#23677
  • Loading branch information
kebeclibre committed Mar 20, 2018
1 parent 2da8d41 commit d1dccd5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/account_voucher/models/account_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def onchange_date(self):

@api.onchange('partner_id', 'pay_now')
def onchange_partner_id(self):
pay_journal_domain = [('type', 'in', ['cash', 'bank'])]
if self.pay_now != 'pay_now':
if self.partner_id:
self.account_id = self.partner_id.property_account_receivable_id \
Expand All @@ -155,6 +156,12 @@ def onchange_partner_id(self):
domain = [('deprecated', '=', False), ('internal_type', '=', account_type)]

self.account_id = self.env['account.account'].search(domain, limit=1)
else:
if self.voucher_type == 'purchase':
pay_journal_domain.append(('outbound_payment_method_ids', '!=', False))
else:
pay_journal_domain.append(('inbound_payment_method_ids', '!=', False))
return {'domain': {'payment_journal_id': pay_journal_domain}}

@api.multi
def proforma_voucher(self):
Expand Down

0 comments on commit d1dccd5

Please sign in to comment.