Amit Dodiya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado into 
lp:openobject-addons/6.1.

Requested reviews:
  Xavier ALT (OpenERP) (xal-openerp)
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado/+merge/133235

Hello,

[FIX]: this issues happens with specific scenario (1) when we have no 
receivable / payable account set for a customer and we try to create and 
invoice from sale order it gives traceback (2) also when we select that 
customer in invoice it gives traceback

Common Configuration:
1). Create DB without demo data and create one customer.

Issue 1 steps): 
1). Installed Account module and configure sales journal.
2). Try to create a customer invoice.
select that created customer GOT ERROR.

Issue 2 steps):
1). Installed sale module and configure sales journal.
2). configure product with income account set.
Try to create a sale order with the above product and confirm it
When you validate you get the following SQL error.

Regards,
Amit
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado/+merge/133235
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py	2012-10-05 12:58:20 +0000
+++ account/account_invoice.py	2012-11-07 12:55:24 +0000
@@ -413,38 +413,38 @@
 
         opt = [('uid', str(uid))]
         if partner_id:
-
             opt.insert(0, ('id', partner_id))
             res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['contact', 'invoice'])
             contact_addr_id = res['contact']
             invoice_addr_id = res['invoice']
             p = self.pool.get('res.partner').browse(cr, uid, partner_id)
-            if company_id:
-                if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id:
-                    property_obj = self.pool.get('ir.property')
-                    rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
-                    pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
-                    if not rec_pro_id:
-                        rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
-                    if not pay_pro_id:
-                        pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
-                    rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id'])
-                    pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id'])
-                    rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False
-                    pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
-                    if not rec_res_id and not pay_res_id:
-                        raise osv.except_osv(_('Configuration Error !'),
-                            _('Can not find a chart of accounts for this company, you should create one.'))
-                    account_obj = self.pool.get('account.account')
-                    rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
-                    pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
-                    p.property_account_receivable = rec_obj_acc[0]
-                    p.property_account_payable = pay_obj_acc[0]
-
-            if type in ('out_invoice', 'out_refund'):
-                acc_id = p.property_account_receivable.id
-            else:
-                acc_id = p.property_account_payable.id
+            if p.property_account_receivable and p.property_account_payable:
+                if company_id:
+                    if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id:
+                        property_obj = self.pool.get('ir.property')
+                        rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
+                        pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
+                        if not rec_pro_id:
+                            rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
+                        if not pay_pro_id:
+                            pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
+                        rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id'])
+                        pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id'])
+                        rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False
+                        pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False
+                        if not rec_res_id and not pay_res_id:
+                            raise osv.except_osv(_('Configuration Error !'),
+                                _('Can not find a chart of accounts for this company, you should create one.'))
+                        account_obj = self.pool.get('account.account')
+                        rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
+                        pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
+                        p.property_account_receivable = rec_obj_acc[0]
+                        p.property_account_payable = pay_obj_acc[0]
+    
+                if type in ('out_invoice', 'out_refund'):
+                    acc_id = p.property_account_receivable.id
+                else:
+                    acc_id = p.property_account_payable.id
             fiscal_position = p.property_account_position and p.property_account_position.id or False
             partner_payment_term = p.property_payment_term and p.property_payment_term.id or False
             if p.bank_ids:

=== modified file 'sale/sale.py'
--- sale/sale.py	2012-10-09 12:16:14 +0000
+++ sale/sale.py	2012-11-07 12:55:24 +0000
@@ -476,6 +476,12 @@
         wf_service = netsvc.LocalService("workflow")
         inv_ids = set()
         inv_ids1 = set()
+        
+        #Added the condition for checking receivable / payable account 
+        customer_record = self.browse(cr, uid, ids)[0].partner_id
+        if not customer_record.property_account_receivable or not customer_record.property_account_payable:
+            raise osv.except_osv(_('Configuration Error !'), _('Please define receivable / payable account for selected customer !'))
+        
         for id in ids:
             for record in self.pool.get('sale.order').browse(cr, uid, id).invoice_ids:
                 inv_ids.add(record.id)

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to