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 = {