[FIX] models: custom models must add the table/column in database
This revision is related to 1b8c9aed9f
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
This commit is contained in:
parent
5b60c30a6a
commit
03ec39d36b
|
@ -208,7 +208,7 @@ class ir_model(osv.osv):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
res = super(ir_model,self).create(cr, user, vals, 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
|
# add model in registry
|
||||||
self.instanciate(cr, user, vals['model'], context)
|
self.instanciate(cr, user, vals['model'], context)
|
||||||
self.pool.setup_models(cr, partial=(not self.pool.ready))
|
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!'))
|
raise except_orm(_('Error'), _('For selection fields, the Selection Options must be given!'))
|
||||||
self._check_selection(cr, user, vals['selection'], context=context)
|
self._check_selection(cr, user, vals['selection'], context=context)
|
||||||
res = super(ir_model_fields,self).create(cr, user, vals, 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_'):
|
if not vals['name'].startswith('x_'):
|
||||||
raise except_orm(_('Error'), _("Custom fields must have a name that starts with '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!'))
|
raise except_orm(_('Error!'), _('Can only rename one column at a time!'))
|
||||||
if vals['name'] in obj._columns:
|
if vals['name'] in obj._columns:
|
||||||
raise except_orm(_('Error!'), _('Cannot rename column to %s, because that column already exists!') % vals['name'])
|
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!'))
|
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']:
|
if '\'' in vals['name'] or '"' in vals['name'] or ';' in vals['name']:
|
||||||
raise ValueError('Invalid character in column name')
|
raise ValueError('Invalid character in column name')
|
||||||
|
|
Loading…
Reference in New Issue