diff --git a/addons/account_voucher/models/account_voucher.py b/addons/account_voucher/models/account_voucher.py index 59fa235534c..ca379a8d315 100644 --- a/addons/account_voucher/models/account_voucher.py +++ b/addons/account_voucher/models/account_voucher.py @@ -146,6 +146,7 @@ class AccountVoucher(models.Model): @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 \ @@ -155,6 +156,12 @@ class AccountVoucher(models.Model): 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):