[FIX] account_voucher: select the right credit/debit account for the payment
If different debit/credit accounts are configured for a journal, the appropriate account must be selected. opw-640745
This commit is contained in:
parent
d9e8c3ade4
commit
e470385d55
|
@ -573,7 +573,12 @@ class account_voucher(osv.osv):
|
||||||
else:
|
else:
|
||||||
if not journal.default_credit_account_id or not journal.default_debit_account_id:
|
if not journal.default_credit_account_id or not journal.default_debit_account_id:
|
||||||
raise osv.except_osv(_('Error!'), _('Please define default credit/debit accounts on the journal "%s".') % (journal.name))
|
raise osv.except_osv(_('Error!'), _('Please define default credit/debit accounts on the journal "%s".') % (journal.name))
|
||||||
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
if ttype in ('sale', 'receipt'):
|
||||||
|
account_id = journal.default_debit_account_id.id
|
||||||
|
elif ttype in ('purchase', 'payment'):
|
||||||
|
account_id = journal.default_credit_account_id.id
|
||||||
|
else:
|
||||||
|
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
||||||
tr_type = 'receipt'
|
tr_type = 'receipt'
|
||||||
|
|
||||||
default['value']['account_id'] = account_id
|
default['value']['account_id'] = account_id
|
||||||
|
@ -665,6 +670,10 @@ class account_voucher(osv.osv):
|
||||||
account_id = partner.property_account_receivable.id
|
account_id = partner.property_account_receivable.id
|
||||||
elif journal.type in ('purchase', 'purchase_refund','expense'):
|
elif journal.type in ('purchase', 'purchase_refund','expense'):
|
||||||
account_id = partner.property_account_payable.id
|
account_id = partner.property_account_payable.id
|
||||||
|
elif ttype in ('sale', 'receipt'):
|
||||||
|
account_id = journal.default_debit_account_id.id
|
||||||
|
elif ttype in ('purchase', 'payment'):
|
||||||
|
account_id = journal.default_credit_account_id.id
|
||||||
else:
|
else:
|
||||||
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
||||||
|
|
||||||
|
@ -921,7 +930,12 @@ class account_voucher(osv.osv):
|
||||||
return False
|
return False
|
||||||
journal_pool = self.pool.get('account.journal')
|
journal_pool = self.pool.get('account.journal')
|
||||||
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
journal = journal_pool.browse(cr, uid, journal_id, context=context)
|
||||||
account_id = journal.default_credit_account_id or journal.default_debit_account_id
|
if ttype in ('sale', 'receipt'):
|
||||||
|
account_id = journal.default_debit_account_id
|
||||||
|
elif ttype in ('purchase', 'payment'):
|
||||||
|
account_id = journal.default_credit_account_id
|
||||||
|
else:
|
||||||
|
account_id = journal.default_credit_account_id or journal.default_debit_account_id
|
||||||
tax_id = False
|
tax_id = False
|
||||||
if account_id and account_id.tax_ids:
|
if account_id and account_id.tax_ids:
|
||||||
tax_id = account_id.tax_ids[0].id
|
tax_id = account_id.tax_ids[0].id
|
||||||
|
@ -1012,6 +1026,10 @@ class account_voucher(osv.osv):
|
||||||
account_id = partner.property_account_receivable.id
|
account_id = partner.property_account_receivable.id
|
||||||
elif journal.type in ('purchase', 'purchase_refund','expense'):
|
elif journal.type in ('purchase', 'purchase_refund','expense'):
|
||||||
account_id = partner.property_account_payable.id
|
account_id = partner.property_account_payable.id
|
||||||
|
elif ttype in ('sale', 'receipt'):
|
||||||
|
account_id = journal.default_debit_account_id.id
|
||||||
|
elif ttype in ('purchase', 'payment'):
|
||||||
|
account_id = journal.default_credit_account_id.id
|
||||||
else:
|
else:
|
||||||
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id
|
||||||
if account_id:
|
if account_id:
|
||||||
|
|
Loading…
Reference in New Issue