[FIX] account_invoice_layout : Fixed the issue with the account in invoice lines...
authorAnup (OpenERP) <ach@tinyerp.com>
Fri, 20 May 2011 12:07:01 +0000 (17:37 +0530)
committerAnup (OpenERP) <ach@tinyerp.com>
Fri, 20 May 2011 12:07:01 +0000 (17:37 +0530)
lp bug: https://launchpad.net/bugs/784499 fixed

bzr revid: ach@tinyerp.com-20110520120701-chejiloauw8oyfyd

1  2 
addons/account_invoice_layout/account_invoice_layout.py

@@@ -165,9 -165,10 +165,11 @@@ class account_invoice_line(osv.osv)
      }
  
      def _default_account(self, cr, uid, context=None):
-         cr.execute("select id from account_account where parent_id IS NULL LIMIT 1")
-         res = cr.fetchone()
-         return res[0]
++        if context is None:
++            context = {}
+         current_company = self.pool.get('res.users').browse(cr,uid,uid).company_id.id
 -        cr.execute("select id from account_account where company_id = %s and parent_id IS NULL LIMIT 1", [current_company])
 -        res = cr.fetchone()
 -        return res[0]
++        account_id = self.pool.get('account.account').search(cr, uid, [('company_id','=',current_company),('parent_id','=',False)], limit=1,context=context)
++        return account_id and account_id[0] or False
  
      _defaults = {
          'state': 'article',