[stable 6.0][trunk]property fields deleted for other companies if Admin user in multiple companies

Bug #712254 reported by Graeme Gellatly
32
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP's Framework R&D

Bug Description

This one is really hard to describe. Basically I needed to override the supply_method selection field in product module to make it a char so products we produce in one company but buy in others can be kept together.

I did this with this code.

class product_template(osv.osv):
    _inherit = "product.template"
    _description = "Product Template"
    _columns={
        'supply_method': fields.property('product.template',
            type='char',
            string='Supply Method',
            method=True,
            view_load=True,
            required=True,
            help="Produce will generate production order or tasks, according to the product type. Purchase will trigger purchase orders when requested. This has been overridden values other than 'produce' or 'buy' will cause errors"),
        }
product_template()

If I modify products as a normal user of Company A -> expected results occur in db, product template form & in configuration -> parameters.
However if i modify as Admin user (with full rights to all companies and groups) in HQ company, it modifies the HQ entry as expected, but deletes the Company A entry.
If I remove admin user from Company A it still deletes company A entry.
If I create a new HQ user (with full rights to HQ and all groups) it behaves as expected.
If I add Company A to HQ user rights (full rights to companies and groups) it behaves as expected.

Next I checked a many2one field not coded by me -> property_account_payable
Selected a partner and gave them a creditor account in Company A and HQ using the users A and HQ
Updating by any other user is fine, updating as Admin deletes the entries for other companies.

So what is going on with Admin user in property fields?

Related branches

Changed in openobject-server:
status: New → Triaged
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello Graeme,

Your explanation is perfectly clear, and after scanning the code for a second, it looks like the framework will try to delete the current value for the property before assigning the new value, and does so according to the current property value you are supposed to see.
However as the admin user bypasses completely all access rules (ir.rule entries), it is in fact allowed to see all property values, and they end up all deleted.

We need to improve that logic and properly update the values no matter what other values you can access.

Thanks for the excellent bug report!

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Medium
milestone: none → 6.0.2
status: Triaged → Confirmed
Revision history for this message
Graeme Gellatly (gdgellatly) wrote :

Has this been fixed yet?

Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello,

Thanks for reporting.

It has been fixed at lp:~openerp-dev/openobject-server/trunk-bug-712254-ysa and it will be merged soon to the trunk server.

Thanks,

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

Graeme Gellatly,

For the heads-up

While solving this bug, we found out that the problem needs some rewriting dealing with ir.property, multi_company.default and the property field, a rewriting that was already planed for another related problem.

We have someone working on it shortly.

Changed in openobject-server:
status: Fix Committed → Confirmed
milestone: 6.0.2 → none
Revision history for this message
Jigar A. (ifixthat) wrote :

Hello,
     Based on Bug report and Comment#4, I have re-write the ir_property write function, and committed in lp:~openerp-dev/openobject-server/trunk-bug-712254-jam and have proposed for merging (mp:104914) in server trunk branch.
@Graeme Gellatly : Thanks for you nice explanation and your time.
Thank You

Changed in openobject-server:
status: Confirmed → In Progress
status: In Progress → Fix Committed
Revision history for this message
Asgardinho (felipereyesazul) wrote :

Hello,
I applied the patch, now with admin user, I can edit and create the property correctly, but when I try to put a null value in a property field, it won't delete it, also the filter does not work the same way it works for a different user.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.