[FIX]ir_property: If we add a property on a many2one field with multicompany the...
authorAmit Dodiya <ado@tinyerp.com>
Tue, 4 Jun 2013 11:01:37 +0000 (16:31 +0530)
committerAmit Dodiya <ado@tinyerp.com>
Tue, 4 Jun 2013 11:01:37 +0000 (16:31 +0530)
bzr revid: ado@tinyerp.com-20130604110137-jclbsmkohs5mm66w

1  2 
openerp/osv/fields.py

@@@ -1379,11 -1379,11 +1379,10 @@@ class property(function)
              res[prop_name] = prop.get(cr, uid, prop_name, obj._name, context=context)
          return res
  
-     def _get_by_id(self, obj, cr, uid, prop_name, ids, context=None):
+     def _get_by_id(self, obj, cr, uid, prop_name, ids, context=None, company_id=False):
          prop = obj.pool.get('ir.property')
          vids = [obj._name + ',' + str(oid) for oid in  ids]
--
-         domain = [('fields_id.model', '=', obj._name), ('fields_id.name', 'in', prop_name)]
+         domain = [('fields_id.model', '=', obj._name), ('fields_id.name', 'in', prop_name), ('company_id', '=', company_id)]
          #domain = prop._get_domain(cr, uid, prop_name, obj._name, context)
          if vids:
              domain = [('res_id', 'in', vids)] + domain
          if context is None:
              context = {}
  
-         nids = self._get_by_id(obj, cr, uid, [prop_name], [id], context)
+         def_id = self._field_get(cr, uid, obj._name, prop_name)
+         company = obj.pool.get('res.company')
 -        cid = company._company_default_get(cr, uid, obj._name, def_id,
 -                                               context=context)
 -        nids = self._get_by_id(obj, cr, uid, [prop_name], [id], context)
++        cid = company._company_default_get(cr, uid, obj._name, def_id, context=context)
++        nids = self._get_by_id(obj, cr, uid, [prop_name], [id], context, company_id=cid)
          if nids:
              cr.execute('DELETE FROM ir_property WHERE id IN %s', (tuple(nids),))