From 03ec39d36befa6687c51f2e3341b038f67c3a116 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 27 Nov 2015 13:54:23 +0100 Subject: [PATCH] [FIX] models: custom models must add the table/column in database This revision is related to 1b8c9aed9f516df1c7a51db41e083df2e36b4bf5 As `manual` is now the default value of the `state`, if `state` is not given in the values when passed to `create` or `write` of `ir.model` and `ir.model.fields`, we must assume the value is `manual`, so the columns and tables are instanciated in database opw-657750 --- openerp/addons/base/ir/ir_model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index ab21f4b8d50..3a9f030b895 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -208,7 +208,7 @@ class ir_model(osv.osv): if context is None: context = {} res = super(ir_model,self).create(cr, user, vals, context) - if vals.get('state','base')=='manual': + if vals.get('state','manual')=='manual': # add model in registry self.instanciate(cr, user, vals['model'], context) self.pool.setup_models(cr, partial=(not self.pool.ready)) @@ -372,7 +372,7 @@ class ir_model_fields(osv.osv): raise except_orm(_('Error'), _('For selection fields, the Selection Options must be given!')) self._check_selection(cr, user, vals['selection'], context=context) res = super(ir_model_fields,self).create(cr, user, vals, context) - if vals.get('state','base') == 'manual': + if vals.get('state','manual') == 'manual': if not vals['name'].startswith('x_'): raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !")) @@ -445,7 +445,7 @@ class ir_model_fields(osv.osv): raise except_orm(_('Error!'), _('Can only rename one column at a time!')) if vals['name'] in obj._columns: raise except_orm(_('Error!'), _('Cannot rename column to %s, because that column already exists!') % vals['name']) - if vals.get('state', 'base') == 'manual' and not vals['name'].startswith('x_'): + if vals.get('state', 'manual') == 'manual' and not vals['name'].startswith('x_'): raise except_orm(_('Error!'), _('New column name must still start with x_ , because it is a custom field!')) if '\'' in vals['name'] or '"' in vals['name'] or ';' in vals['name']: raise ValueError('Invalid character in column name')