Josse Colpaert (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-1084819-jco into 
lp:openobject-addons.

Requested reviews:
  qdp (OpenERP) (qdp)
Related bugs:
  Bug #1084819 in OpenERP Addons: "Defatult Expense Category Account 
disregarded"
  https://bugs.launchpad.net/openobject-addons/+bug/1084819

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1084819-jco/+merge/141051

As described in commit: _default_account_id in invoice line depends now on type 
in context (whether customer/supplier invoice or refund)
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-1084819-jco/+merge/141051
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-1084819-jco.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py	2012-12-20 11:47:30 +0000
+++ account/account_invoice.py	2012-12-21 10:11:22 +0000
@@ -1393,8 +1393,13 @@
     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 = {

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : openerp-dev-gtk@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to