Merge lp:~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado into lp:openobject-addons/6.1

Proposed by Amit Dodiya (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado
Merge into: lp:openobject-addons/6.1
Diff against target: 86 lines (+33/-27)
2 files modified
account/account_invoice.py (+27/-27)
sale/sale.py (+6/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-578572_578611-ado
Reviewer Review Type Date Requested Status
Xavier ALT Pending
Naresh(OpenERP) Pending
Review via email: mp+133235@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-578572_578611-port-mma/+merge/136140 and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Thanks,
Naresh Soni

Unmerged revisions

6968. By Amit Dodiya<email address hidden>

[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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_invoice.py'
2--- account/account_invoice.py 2012-10-05 12:58:20 +0000
3+++ account/account_invoice.py 2012-11-07 12:55:24 +0000
4@@ -413,38 +413,38 @@
5
6 opt = [('uid', str(uid))]
7 if partner_id:
8-
9 opt.insert(0, ('id', partner_id))
10 res = self.pool.get('res.partner').address_get(cr, uid, [partner_id], ['contact', 'invoice'])
11 contact_addr_id = res['contact']
12 invoice_addr_id = res['invoice']
13 p = self.pool.get('res.partner').browse(cr, uid, partner_id)
14- if company_id:
15- if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id:
16- property_obj = self.pool.get('ir.property')
17- rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
18- pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
19- if not rec_pro_id:
20- rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
21- if not pay_pro_id:
22- pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
23- rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id'])
24- pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id'])
25- 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
26- 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
27- if not rec_res_id and not pay_res_id:
28- raise osv.except_osv(_('Configuration Error !'),
29- _('Can not find a chart of accounts for this company, you should create one.'))
30- account_obj = self.pool.get('account.account')
31- rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
32- pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
33- p.property_account_receivable = rec_obj_acc[0]
34- p.property_account_payable = pay_obj_acc[0]
35-
36- if type in ('out_invoice', 'out_refund'):
37- acc_id = p.property_account_receivable.id
38- else:
39- acc_id = p.property_account_payable.id
40+ if p.property_account_receivable and p.property_account_payable:
41+ if company_id:
42+ if p.property_account_receivable.company_id.id != company_id and p.property_account_payable.company_id.id != company_id:
43+ property_obj = self.pool.get('ir.property')
44+ rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
45+ pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(partner_id)+''),('company_id','=',company_id)])
46+ if not rec_pro_id:
47+ rec_pro_id = property_obj.search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)])
48+ if not pay_pro_id:
49+ pay_pro_id = property_obj.search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)])
50+ rec_line_data = property_obj.read(cr,uid,rec_pro_id,['name','value_reference','res_id'])
51+ pay_line_data = property_obj.read(cr,uid,pay_pro_id,['name','value_reference','res_id'])
52+ 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
53+ 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
54+ if not rec_res_id and not pay_res_id:
55+ raise osv.except_osv(_('Configuration Error !'),
56+ _('Can not find a chart of accounts for this company, you should create one.'))
57+ account_obj = self.pool.get('account.account')
58+ rec_obj_acc = account_obj.browse(cr, uid, [rec_res_id])
59+ pay_obj_acc = account_obj.browse(cr, uid, [pay_res_id])
60+ p.property_account_receivable = rec_obj_acc[0]
61+ p.property_account_payable = pay_obj_acc[0]
62+
63+ if type in ('out_invoice', 'out_refund'):
64+ acc_id = p.property_account_receivable.id
65+ else:
66+ acc_id = p.property_account_payable.id
67 fiscal_position = p.property_account_position and p.property_account_position.id or False
68 partner_payment_term = p.property_payment_term and p.property_payment_term.id or False
69 if p.bank_ids:
70
71=== modified file 'sale/sale.py'
72--- sale/sale.py 2012-10-09 12:16:14 +0000
73+++ sale/sale.py 2012-11-07 12:55:24 +0000
74@@ -476,6 +476,12 @@
75 wf_service = netsvc.LocalService("workflow")
76 inv_ids = set()
77 inv_ids1 = set()
78+
79+ #Added the condition for checking receivable / payable account
80+ customer_record = self.browse(cr, uid, ids)[0].partner_id
81+ if not customer_record.property_account_receivable or not customer_record.property_account_payable:
82+ raise osv.except_osv(_('Configuration Error !'), _('Please define receivable / payable account for selected customer !'))
83+
84 for id in ids:
85 for record in self.pool.get('sale.order').browse(cr, uid, id).invoice_ids:
86 inv_ids.add(record.id)