ir.model.field copy is impossible (in most cases)

Bug #559346 reported by Xavier Fernandez http://www.smile.fr on 2010-04-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
Unassigned

Bug Description

If a field('ir.model.fields') is not a relation (m2o, o2m, m2m or function) the 'relation' of the object 'ir.model.fields' will contain the value 'NULL' (and by 'NULL', I mean the 'NULL' string, cf _field_create function in orm.py) in the database (which is kind of ugly).

Then when you call the function copy() on an 'ir.model.fields', it will call the create function with a 'vals' dictionnary containing the field 'relation' containing 'NULL' and this check will fail:

if 'relation' in vals and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]):

Indeed, the model named 'NULL' does not exist. Overloading the copy function using a 'default' dictionnary is not even a solution because setting 'relation' to False will only give a different error: now the model False does not exist.

So modifying the check to:
if vals.get('relation', False) and not self.pool.get('ir.model').search(cr, user, [('model','=',vals['relation'])]):
seems a good (and harmless) thing to do in order to give the possibility to use the copy function with a default dictionnary.

And setting the default value of relation to '' instead of 'NULL' seems like a cleaner solution (but I'm not sure this 'NULL' value is not used somewhere else...)

Related branches

Changed in openobject-server:
status: New → Confirmed
Changed in openobject-server:
status: Confirmed → In Progress

Fixed by revision 2036 <email address hidden>.
Thanks for your interest.

Changed in openobject-server:
importance: Undecided → Medium
milestone: none → 5.0.10
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers