c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #08984
[Bug 691541] Re: Company ID in properties
Hi,
For our scenario to work correctly, we had to add some lines of code to the class "property", function: _fnct_read( ... )
The difference is only between the comments. Here is the code we use:
properties = obj.pool.get('ir.property')
domain = [('fields_id.model', '=', obj._name), ('fields_id.name','in',prop_name)]
domain += [('res_id','in', [obj._name + ',' + str(oid) for oid in ids])]
#------------------------------------------------------------------------
# patch by cyp@xxxxxxxxxxx => company_id handled while reading properties
#
prop = prop_name
if isinstance(prop_name,list):
prop = prop_name[0]
def_id = self._field_get(cr, uid, obj._name, prop)
company = obj.pool.get('res.company')
cid = company._company_default_get(cr, uid, obj._name, def_id,
context=context)
if cid:
domain += [('company_id','=',cid)]
#
#------------------------------------------------------------------------
nids = properties.search(cr, uid, domain, context=context)
default_val,replaces = self._get_defaults(obj, cr, uid, prop_name, context)
res = {}
for id in ids:
res[id] = default_val.copy()
brs = properties.browse(cr, uid, nids, context=context)
for prop in brs:
value = properties.get_by_record(cr, uid, prop, context=context)
res[prop.res_id.id][prop.fields_id.name] = value or False
if value and (prop.type == 'many2one'):
replaces.setdefault(value._name, {})
replaces[value._name][value.id] = True
for rep in replaces:
replaces[rep] = dict(obj.pool.get(rep).name_get(cr, uid, replaces[rep].keys(), context=context))
for prop in prop_name:
for id in ids:
if res[id][prop] and hasattr(res[id][prop], '_name'):
res[id][prop] = (res[id][prop].id , replaces[res[id][prop]._name].get(res[id][prop].id, False))
return res
The idea was to add one more item to the domain, using the same code as
the function _fnct_write( ... ) uses.
In this scenario, you'll end up with at least two rows in the table 'ir_property':
1. consider we have the res_partner ID: 918 (just an example)
2: using pgadmin, filter your table with: "res_id='res.partner,918' and name='property_account_receivable'"
3.for each row, the "company_id" column should have a different value (following the fact that the user changes the company he is working for), while the field: value_reference is showing your choices (the property "Payable account" is a many2one)
4. the original code *seems* not to be using this column in the search in the function: _fnct_read( ... )
5. with the patch I am proposing, it handles company_id correctly to read the property
Best regards
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/691541
Title:
Company ID in properties
Status in OpenObject Server:
Incomplete
Bug description:
We did the following test on OE server 6-trunk:
In multi-company mode:
1. the user is working for company A
1. setup the accounts receivable/Payable for a partner
2. change the company the user is working for (user preferences): the company B for example
3. setup other accounts receivable/Payable for the partner (select for the new company)
4. change your user's company: re-select company A
5. reload your partner: the account properties will keep the ones with the highest Database ID, ignoring the company
We've looked at the source: osv/fields.py, class: property
1. the function: _fnct_write( .... ) seems to use the user's default company
2. in the function: _fnct_read( ... ), this does not look really obvious that the user's company is taken into account
We suspect that the write process is correct, and the read process seems to fail
Best regards
References