fields.related override: store function persists

Bug #789576 reported by Stefan Rijnhart (Opener)
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
OpenERP's Framework R&D

Bug Description

Hi,

when a fields.related is overridden by a regular field, the store function is not removed. Values assigned to the field by the users of the system get overwritten immediately by the store function of the original field definition.

Here is an example from the HR module:

'parent_id': fields.related('department_id', 'manager_id', relation='hr.employee', string='Manager', type='many2one', store=True, select=True, readonly=True, help="It is linked with manager of Department"),

We want to override this definition with "fields.many2one('hr.employee', 'Manager')", but any write on this field triggers a recalculation based on the related field.

The problem is in orm.__init__() where the list of a model's store functions is populated but never purged.

Reproducable with openerp-server/6.0 rev. 3435.

Cheers,
Stefan.

Related branches

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Medium
status: New → Confirmed
summary: - [6.0] fields.related override: store function persists
+ fields.related override: store function persists
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Nimesh Contractor(Open ERP) (nco-openerp) wrote :

Hello,
    Stefan Rijnhart (Therp), thanks for the merge proposal in v6.0
    It has been fixed in https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-789576-nco/+merge/65303
    It will be available in trunk also.

Thank you.

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Nimesh,

thank you for having a look and porting my fix to trunk. Can you please merge my fix with 6.0? It has been two months now.

Cheers,
Stefan.

Revision history for this message
Vo Minh Thu (thu) wrote :

I change the status of this bug report. You can see the reason on the merge proposal, copy/pasted here:

The idea seems good.

Instead of removing the function when the field is not a function field or not stored, we can in fact always remove it. This means the loop (a few lines below the changed code) to test if the current function will be appended or not can be removed.

The for-loop with calls to list.remove() is not safe (as it changes the iterated list). You can use instead a list comprehension ar a call to filter().

Changed in openobject-server:
status: Fix Committed → In Progress
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Thanks for reporting !

it has been improved at lp:~openerp-dev/openobject-server/trunk-bug-789576-nch

regards,

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

The fix landed in trunk at revision 3712, revision-id: <email address hidden>

Thanks for the bug report!

Changed in openobject-server:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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