diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 66da370e2f7..cc3bf481b40 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -573,7 +573,12 @@ class account_voucher(osv.osv): else: 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)) - 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' default['value']['account_id'] = account_id @@ -665,6 +670,10 @@ class account_voucher(osv.osv): account_id = partner.property_account_receivable.id elif journal.type in ('purchase', 'purchase_refund','expense'): 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: 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 journal_pool = self.pool.get('account.journal') 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 if account_id and account_id.tax_ids: tax_id = account_id.tax_ids[0].id @@ -1012,6 +1026,10 @@ class account_voucher(osv.osv): account_id = partner.property_account_receivable.id elif journal.type in ('purchase', 'purchase_refund','expense'): 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: account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id if account_id: