[FIX] Custom fields won't disturb anything while updating server

lp bug: https://launchpad.net/bugs/493657 fixed

bzr revid: jvo@tinyerp.com-20100209091328-sllcv1fjo4qq59a3
This commit is contained in:
Jay (Open ERP) 2010-02-09 14:43:28 +05:30
parent 8fa3951b8c
commit ba22f3edfa
2 changed files with 12 additions and 3 deletions

View File

@ -75,7 +75,7 @@ class ir_model(osv.osv):
if context:
context.pop('__last_update', None)
return super(ir_model,self).write(cr, user, ids, vals, context)
def create(self, cr, user, vals, context=None):
if context and context.get('manual',False):
vals['state']='manual'
@ -83,7 +83,9 @@ class ir_model(osv.osv):
if vals.get('state','base')=='manual':
self.instanciate(cr, user, vals['model'], context)
self.pool.get(vals['model']).__init__(self.pool, cr)
self.pool.get(vals['model'])._auto_init(cr,{'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0')})
ctx = context.copy()
ctx.update({'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0')})
self.pool.get(vals['model'])._auto_init(cr, ctx)
#pooler.restart_pool(cr.dbname)
return res
@ -260,9 +262,12 @@ class ir_model_fields(osv.osv):
if self.pool.get(vals['model']):
self.pool.get(vals['model']).__init__(self.pool, cr)
#Added context to _auto_init for special treatment to custom field for select_level
self.pool.get(vals['model'])._auto_init(cr, {'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0')})
ctx = context.copy()
ctx.update({'field_name':vals['name'],'field_state':'manual','select':vals.get('select_level','0'),'update_custom_fields':True})
self.pool.get(vals['model'])._auto_init(cr, ctx)
return res
ir_model_fields()
class ir_model_access(osv.osv):

View File

@ -1771,10 +1771,14 @@ class orm(orm_template):
# iterate on the "object columns"
todo_update_store = []
update_custom_fields = context.get('update_custom_fields', False)
for k in self._columns:
if k in ('id', 'write_uid', 'write_date', 'create_uid', 'create_date'):
continue
#raise _('Can not define a column %s. Reserved keyword !') % (k,)
#Not Updating Custom fields
if k.startswith('x_') and not update_custom_fields:
continue
f = self._columns[k]
if isinstance(f, fields.one2many):