Merge lp:~openerp-dev/openobject-server/6.0-opw-51093-skh into lp:openobject-server/6.0

Proposed by Somesh Khare
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: 3559
Merged at revision: 3573
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-51093-skh
Merge into: lp:openobject-server/6.0
Diff against target: 56 lines (+16/-7)
1 file modified
bin/addons/base/ir/ir_values.py (+16/-7)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-51093-skh
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Approve
Vinay Rana (OpenERP) Pending
Review via email: mp+86793@code.launchpad.net

Description of the change

Hello Sir,

Scenario:
If you setup two companies (A, then B) in 6.0.2 with differnt Chart of Accounts and then

- create a Product with a User from Company B, the Default Tax is applied.
- create a Product with a User from Company A, NO Default Tax is applied.

It seems like the Records (taxes_id, supplier_taxes) in ir.values from Company A are being replaced while configuring the second Chart of Accounts for Company B.

[Fix]: This issue fixed into the branch, Kindly review the branch and please share your views on it.

Thanks,
Somesh Khare

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/base/ir/ir_values.py'
2--- bin/addons/base/ir/ir_values.py 2010-12-06 13:19:28 +0000
3+++ bin/addons/base/ir/ir_values.py 2011-12-23 10:18:24 +0000
4@@ -106,6 +106,12 @@
5 value = pickle.dumps(value)
6 if meta:
7 meta = pickle.dumps(meta)
8+ assert isinstance(models, (list, tuple)), models
9+ assert not company or isinstance(company, int), "Parameter 'company' must be an integer (company ID)!"
10+ if company and company is True:
11+ current_user_obj = self.pool.get('res.users').browse(cr, uid, uid, context={})
12+ company = current_user_obj.company_id.id
13+
14 ids_res = []
15 for model in models:
16 if isinstance(model, (list, tuple)):
17@@ -118,7 +124,9 @@
18 ('key2', '=', key2),
19 ('model', '=', model),
20 ('res_id', '=', res_id),
21- ('user_id', '=', preserve_user and uid)
22+ ('user_id', '=', preserve_user and uid),
23+ ('company_id' ,'=', company)
24+
25 ]
26 if key in ('meta', 'default'):
27 search_criteria.append(('name', '=', name))
28@@ -135,12 +143,10 @@
29 'key2': key2 and key2[:200],
30 'meta': meta,
31 'user_id': preserve_user and uid,
32+ 'company_id':company
33 }
34- if company:
35- cid = self.pool.get('res.users').browse(cr, uid, uid, context={}).company_id.id
36- vals['company_id']=cid
37 if res_id:
38- vals['res_id']= res_id
39+ vals['res_id'] = res_id
40 ids_res.append(self.create(cr, uid, vals))
41 return ids_res
42
43@@ -173,8 +179,11 @@
44 where.append('res_id=%s')
45 params.append(res_id)
46
47- where.append('(user_id=%s or (user_id IS NULL)) order by id')
48- params.append(uid)
49+ order = 'user_id, company_id'
50+ where.append('''(user_id=%s or (user_id IS NULL))
51+ and (company_id is null or
52+ company_id = (SELECT company_id FROM res_users WHERE id = %s)) order by '''+ order)
53+ params += [uid, uid]
54 clause = ' and '.join(where)
55 cr.execute('select id,name,value,object,meta, key from ir_values where ' + clause, params)
56 result = cr.fetchall()