From dba6e07ecdf8ed61316bdc1f4c4af36e489a95be Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 21 Dec 2012 10:41:47 +0100 Subject: [PATCH] [FIX] Will take into account the type of the invoice for the default account in the invoice line lp bug: https://launchpad.net/bugs/1084819 fixed bzr revid: jco@openerp.com-20121221094147-mp7dhttfob7y2xis --- addons/account/account_invoice.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 02903ea8f33..e836e28d6c6 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1393,8 +1393,13 @@ class account_invoice_line(osv.osv): def _default_account_id(self, cr, uid, context=None): # XXX this gets the default account for the user's company, # it should get the default account for the invoice's company - # however, the invoice's company does not reach this point - prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) + # however, the invoice's company does not reach this point (but will throw error on validation) + if context is None: + context = {} + if context.get('type') in ('out_invoice','out_refund'): + prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) + else: + prop = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category', context=context) return prop and prop.id or False _defaults = {