[FIX] Account_analytic_default : Invoice creation from SO corected
authorJay (Open ERP) <jvo@tinyerp.com>
Thu, 29 Apr 2010 15:31:04 +0000 (21:01 +0530)
committerJay (Open ERP) <jvo@tinyerp.com>
Thu, 29 Apr 2010 15:31:04 +0000 (21:01 +0530)
lp bug: https://launchpad.net/bugs/552455 fixed
lp bug: https://launchpad.net/bugs/567987 fixed

bzr revid: jvo@tinyerp.com-20100429153104-ulg4ju5xan1ang8i

addons/account_analytic_default/account_analytic_default.py
addons/sale/sale.py

index a7ff328..d8f94ba 100644 (file)
@@ -104,6 +104,8 @@ class sale_order_line(osv.osv):
     # Method overridden to set the analytic account by default on criterion match
     def invoice_line_create(self, cr, uid, ids, context={}):
         create_ids = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context)
+        if not ids:
+            return create_ids
         sale_line_obj = self.browse(cr, uid, ids[0], context)
         pool_inv_line = self.pool.get('account.invoice.line')
         
index 61f65a1..f77a63a 100644 (file)
@@ -417,8 +417,6 @@ class sale_order(osv.osv):
             for line in o.order_line:
                 if (line.state in states) and not line.invoiced:
                     lines.append(line.id)
-            if not lines:
-                 raise osv.except_osv(_('Warning'),_('Invoice cannot be created for this Sale Order due to one of the following reasons:\n1.The state is not in %s!\n2.The Sale Order Lines are Invoiced!')%(states,))
             created_lines = self.pool.get('sale.order.line').invoice_line_create(cr, uid, lines)
             if created_lines:
                 invoices.setdefault(o.partner_id.id, []).append((o, created_lines))