Somesh Khare has proposed merging 
lp:~openerp-dev/openobject-server/6.0-opw-51093-skh into 
lp:openobject-server/6.0.

Requested reviews:
  Vinay Rana (openerp) (vra-openerp)
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-51093-skh/+merge/86793

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
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-51093-skh/+merge/86793
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/6.0-opw-51093-skh.
=== modified file 'bin/addons/base/ir/ir_values.py'
--- bin/addons/base/ir/ir_values.py	2010-12-06 13:19:28 +0000
+++ bin/addons/base/ir/ir_values.py	2011-12-23 10:18:24 +0000
@@ -106,6 +106,12 @@
             value = pickle.dumps(value)
         if meta:
             meta = pickle.dumps(meta)
+        assert isinstance(models, (list, tuple)), models
+        assert not company or isinstance(company, int), "Parameter 'company' must be an integer (company ID)!"
+        if company and company is True:
+            current_user_obj = self.pool.get('res.users').browse(cr, uid, uid, context={})
+            company = current_user_obj.company_id.id
+            
         ids_res = []
         for model in models:
             if isinstance(model, (list, tuple)):
@@ -118,7 +124,9 @@
                     ('key2', '=', key2),
                     ('model', '=', model),
                     ('res_id', '=', res_id),
-                    ('user_id', '=', preserve_user and uid)
+                    ('user_id', '=', preserve_user and uid),
+                    ('company_id' ,'=', company)
+                    
                 ]
                 if key in ('meta', 'default'):
                     search_criteria.append(('name', '=', name))
@@ -135,12 +143,10 @@
                 'key2': key2 and key2[:200],
                 'meta': meta,
                 'user_id': preserve_user and uid,
+                'company_id':company
             }
-            if company:
-                cid = self.pool.get('res.users').browse(cr, uid, uid, context={}).company_id.id
-                vals['company_id']=cid
             if res_id:
-                vals['res_id']= res_id
+                vals['res_id'] = res_id
             ids_res.append(self.create(cr, uid, vals))
         return ids_res
 
@@ -173,8 +179,11 @@
                     where.append('res_id=%s')
                     params.append(res_id)
 
-            where.append('(user_id=%s or (user_id IS NULL)) order by id')
-            params.append(uid)
+            order = 'user_id, company_id'
+            where.append('''(user_id=%s or (user_id IS NULL))
+                and (company_id is null or
+                company_id = (SELECT company_id FROM res_users WHERE id = %s)) order by '''+ order)
+            params += [uid, uid]
             clause = ' and '.join(where)
             cr.execute('select id,name,value,object,meta, key from ir_values where ' + clause, params)
             result = cr.fetchall()

_______________________________________________
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