xxxxxxxxxx
1
@api.onchange('partner_id', 'pay_now')
2
def onchange_partner_id(self):
3
pay_journal_domain = [('type', 'in', ['cash', 'bank'])]
4
if self.pay_now != 'pay_now':
5
if self.partner_id:
6
self.account_id = self.partner_id.property_account_receivable_id \
7
if self.voucher_type == 'sale' else self.partner_id.property_account_payable_id
8
else:
9
account_type = self.voucher_type == 'purchase' and 'payable' or 'receivable'
10
domain = [('deprecated', '=', False), ('internal_type', '=', account_type)]
11
12
self.account_id = self.env['account.account'].search(domain, limit=1)
13
else:
14
if self.voucher_type == 'purchase':
15
pay_journal_domain.append(('outbound_payment_method_ids', '!=', False))
16
else:
17
pay_journal_domain.append(('inbound_payment_method_ids', '!=', False))
18
return {'domain': {'payment_journal_id': pay_journal_domain}}
已复制