[IMP] base: remove ir_model_* tables from base.sql

This commit is contained in:
Raphael Collet
2017-02-22 15:24:05 +01:00
parent 2b46025dd5
commit daa1eb1fc4
4 changed files with 10 additions and 77 deletions
-71
View File
@@ -12,49 +12,6 @@ CREATE TABLE ir_act_url (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_act_server (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_act_client (primary key(id)) INHERITS (ir_actions);
CREATE TABLE ir_model (
id serial,
model varchar NOT NULL,
name varchar,
state varchar,
info text,
transient boolean,
primary key(id)
);
CREATE TABLE ir_model_fields (
id serial,
model varchar NOT NULL,
model_id integer references ir_model on delete cascade,
name varchar NOT NULL,
state varchar default 'base',
field_description varchar,
help varchar,
ttype varchar,
relation varchar,
relation_field varchar,
index boolean,
copy boolean,
related varchar,
readonly boolean default False,
required boolean default False,
selectable boolean default False,
translate boolean default False,
relation_table varchar,
column1 varchar,
column2 varchar,
store boolean,
primary key(id)
);
CREATE TABLE res_lang (
id serial,
name VARCHAR(64) NOT NULL UNIQUE,
code VARCHAR(16) NOT NULL UNIQUE,
primary key(id)
);
CREATE TABLE res_users (
id serial NOT NULL,
active boolean default True,
@@ -137,34 +94,6 @@ CREATE TABLE ir_model_data (
primary key(id)
);
-- Records foreign keys and constraints installed by a module (so they can be
-- removed when the module is uninstalled):
-- - for a foreign key: type is 'f',
-- - for a constraint: type is 'u' (this is the convention PostgreSQL uses).
CREATE TABLE ir_model_constraint (
id serial NOT NULL,
date_init timestamp without time zone,
date_update timestamp without time zone,
module integer NOT NULL references ir_module_module on delete restrict,
model integer NOT NULL references ir_model on delete restrict,
type character varying(1) NOT NULL,
definition varchar,
name varchar NOT NULL,
primary key(id)
);
-- Records relation tables (i.e. implementing many2many) installed by a module
-- (so they can be removed when the module is uninstalled).
CREATE TABLE ir_model_relation (
id serial NOT NULL,
date_init timestamp without time zone,
date_update timestamp without time zone,
module integer NOT NULL references ir_module_module on delete restrict,
model integer NOT NULL references ir_model on delete restrict,
name varchar NOT NULL,
primary key(id)
);
CREATE TABLE res_currency (
id serial,
name varchar NOT NULL,
+1
View File
@@ -674,6 +674,7 @@ class IrModelFields(models.Model):
'field_description': field.string,
'help': field.help or None,
'ttype': field.type,
'state': 'manual' if field.manual else 'base',
'relation': field.comodel_name or None,
'index': bool(field.index),
'store': bool(field.store),
+2
View File
@@ -544,6 +544,8 @@ class BaseModel(object):
@api.model
def _add_manual_fields(self, partial):
if not self.pool._init_modules:
return
IrModelFields = self.env['ir.model.fields']
manual_fields = self.pool.get_manual_fields(self._cr, self._name)
for name, field_data in manual_fields.iteritems():
+7 -6
View File
@@ -275,12 +275,13 @@ class Registry(Mapping):
lazy_property.reset_all(self)
env = odoo.api.Environment(cr, SUPERUSER_ID, {})
# load custom models
ir_model = env['ir.model']
cr.execute('SELECT * FROM ir_model WHERE state=%s', ('manual',))
for model_data in cr.dictfetchall():
model_class = ir_model._instanciate(model_data)
model_class._build_model(self, cr)
# load custom models (except when loading 'base')
if self._init_modules:
ir_model = env['ir.model']
cr.execute('SELECT * FROM ir_model WHERE state=%s', ('manual',))
for model_data in cr.dictfetchall():
model_class = ir_model._instanciate(model_data)
model_class._build_model(self, cr)
# prepare the setup on all models
models = env.values()