[IMP] ir_model: remove unnecessary keys from context, and fix the case that needed it

This commit is contained in:
Raphael Collet
2015-08-24 11:10:31 +02:00
parent cae29df7d9
commit 5bb25b198e
2 changed files with 4 additions and 22 deletions
+3 -14
View File
@@ -182,11 +182,7 @@ class ir_model(osv.osv):
self.pool.setup_models(cr, partial=(not self.pool.ready))
# update database schema
model = self.pool[vals['model']]
ctx = dict(context,
field_name=vals['name'],
field_state='manual',
select=vals.get('select_level', '0'),
update_custom_fields=True)
ctx = dict(context, update_custom_fields=True)
model._auto_init(cr, ctx)
model._auto_end(cr, ctx) # actually create FKs!
RegistryManager.signal_registry_change(cr.dbname)
@@ -454,11 +450,7 @@ class ir_model_fields(osv.osv):
self.pool.setup_models(cr, partial=(not self.pool.ready))
# update database schema
model = self.pool[vals['model']]
ctx = dict(context,
field_name=vals['name'],
field_state='manual',
select=vals.get('select_level', '0'),
update_custom_fields=True)
ctx = dict(context, update_custom_fields=True)
model._auto_init(cr, ctx)
model._auto_end(cr, ctx) # actually create FKs!
RegistryManager.signal_registry_change(cr.dbname)
@@ -571,10 +563,7 @@ class ir_model_fields(osv.osv):
# was called earlier, they will be in-sync before the _auto_init.
# Anything we don't update in _columns now will be reset from
# the model into ir.model.fields (db).
ctx = dict(context,
select=vals.get('select_level', '0'),
update_custom_fields=True,
)
ctx = dict(context, update_custom_fields=True)
for obj, model_patches in patches.iteritems():
for field_name, field_patches in model_patches.iteritems():
+1 -8
View File
@@ -404,14 +404,6 @@ class BaseModel(object):
raise UserError(_("Serialization field `%s` not found for sparse field `%s`!") % (f.serialization_field, k))
vals['serialization_field_id'] = serialization_field_id[0]
# When its a custom field,it does not contain f.select
if context.get('field_state', 'base') == 'manual':
if context.get('field_name', '') == k:
vals['select_level'] = context.get('select', '0')
#setting value to let the problem NOT occur next time
elif k in cols:
vals['select_level'] = cols[k]['select_level']
if k not in cols:
cr.execute('select nextval(%s)', ('ir_model_fields_id_seq',))
id = cr.fetchone()[0]
@@ -672,6 +664,7 @@ class BaseModel(object):
attrs = {
'manual': True,
'string': field['field_description'],
'index': bool(int(field['select_level'])),
'copy': bool(field['copy']),
'related': field['related'],
'required': bool(field['required']),