function fields inherited by prototyping still point to the old model

Bug #1179971 reported by Holger Brunn (Therp)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned
OpenERP Community Backports (Server)
New
Undecided
Unassigned

Bug Description

I have a first model:

class A(Model):
_name = 'my.name'
_columns = {
  'test': fields.function(_some_func, ...
    store = {
        'my.name': (lambda self, cr, uid, ids, context: ids, ['a trigger field'], 42),
    }

now I inherit this one:

class B(Model):
_name = 'my.other.name'
_inherit = 'my.name'

What I get now is the same definition for the field 'test', resulting in the attempt to write ids from model 'my.name' into 'my.other.name'. I think when doing inheritance by prototyping, we should walk through the function fields and change eventual keys equal to _inherit to _name.

To verify, inherit res.partner by prototyping. Then all your writes will fail if there if no record of your new model with the same id.

Now I ask myself: Is it worth the effort to propose a patch for that? (the workaround is to redeclare the fields in question in the new model)

Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

Is there any real world code that has problems because of this?

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Yes, mine ;-)

I want to use a TransientModel that inherits from res.partner to have a user fill in data I can just pass to res.partner after some checks. That would have been very elegant it I didn't need clumsy workarounds for all function fields involved.

Revision history for this message
Mayte Montano (mayte-l) wrote :

Mine too!; this is an old post but I have the same problem; inherited account.invoice by prototyping and had to redefine all function fields.

Is there any other more "elegant" way to do it?

I posted question in https://answers.launchpad.net/openobject-addons/+question/255258

Regards

Mayte

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.