2006-12-07 13:41:40 +00:00
|
|
|
-------------------------------------------------------------------------
|
|
|
|
-- Pure SQL
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
-- IR dictionary
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
create table ir_values
|
|
|
|
(
|
|
|
|
id serial,
|
|
|
|
name varchar(128) not null,
|
|
|
|
key varchar(128) not null,
|
2009-02-19 10:04:22 +00:00
|
|
|
key2 varchar(256) not null,
|
2006-12-07 13:41:40 +00:00
|
|
|
model varchar(128) not null,
|
|
|
|
value text,
|
|
|
|
meta text default NULL,
|
|
|
|
res_id integer default null,
|
|
|
|
primary key (id)
|
|
|
|
);
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
-- Modules Description
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
CREATE TABLE ir_model (
|
|
|
|
id serial,
|
2013-11-08 13:02:08 +00:00
|
|
|
model varchar DEFAULT ''::varchar NOT NULL,
|
|
|
|
name varchar,
|
|
|
|
state varchar,
|
2006-12-07 13:41:40 +00:00
|
|
|
info text,
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE ir_model_fields (
|
|
|
|
id serial,
|
2013-11-08 13:02:08 +00:00
|
|
|
model varchar DEFAULT ''::varchar NOT NULL,
|
2007-12-31 13:31:38 +00:00
|
|
|
model_id int references ir_model on delete cascade,
|
2013-11-08 13:02:08 +00:00
|
|
|
name varchar DEFAULT ''::varchar NOT NULL,
|
|
|
|
relation varchar,
|
|
|
|
select_level varchar,
|
|
|
|
field_description varchar,
|
|
|
|
ttype varchar,
|
|
|
|
state varchar default 'base',
|
2006-12-07 13:41:40 +00:00
|
|
|
relate boolean default False,
|
2013-11-08 13:02:08 +00:00
|
|
|
relation_field varchar,
|
2011-05-23 13:21:53 +00:00
|
|
|
translate boolean default False,
|
2008-08-20 19:42:30 +00:00
|
|
|
primary key(id)
|
2006-12-07 13:41:40 +00:00
|
|
|
);
|
|
|
|
|
2011-09-20 17:07:07 +00:00
|
|
|
ALTER TABLE ir_model_fields ADD column serialization_field_id int references ir_model_fields on delete cascade;
|
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
-- Actions
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
CREATE TABLE ir_actions (
|
|
|
|
id serial NOT NULL,
|
|
|
|
name varchar(64) DEFAULT ''::varchar NOT NULL,
|
2012-04-20 15:22:20 +00:00
|
|
|
"type" varchar(32) NOT NULL,
|
2006-12-07 13:41:40 +00:00
|
|
|
usage varchar(32) DEFAULT null,
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE ir_act_window (
|
|
|
|
view_id integer,
|
|
|
|
res_model varchar(64),
|
|
|
|
view_type varchar(16),
|
2009-02-19 10:04:22 +00:00
|
|
|
"domain" varchar(250),
|
2006-12-07 13:41:40 +00:00
|
|
|
primary key(id)
|
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
|
|
|
CREATE TABLE ir_act_report_xml (
|
|
|
|
model varchar(64) NOT NULL,
|
|
|
|
report_name varchar(64) NOT NULL,
|
2009-02-19 10:04:22 +00:00
|
|
|
report_xsl varchar(256),
|
|
|
|
report_xml varchar(256),
|
2007-10-10 13:32:26 +00:00
|
|
|
auto boolean default true,
|
|
|
|
primary key(id)
|
2006-12-07 13:41:40 +00:00
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
|
|
|
create table ir_act_report_custom (
|
2007-10-10 13:32:26 +00:00
|
|
|
report_id int,
|
2006-12-07 13:41:40 +00:00
|
|
|
-- report_id int references ir_report_custom
|
2007-10-10 13:32:26 +00:00
|
|
|
primary key(id)
|
2006-12-07 13:41:40 +00:00
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
|
|
|
CREATE TABLE ir_act_wizard (
|
2007-10-10 13:32:26 +00:00
|
|
|
wiz_name varchar(64) NOT NULL,
|
|
|
|
primary key(id)
|
2006-12-07 13:41:40 +00:00
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
2007-10-25 18:20:12 +00:00
|
|
|
CREATE TABLE ir_act_url (
|
|
|
|
url text NOT NULL,
|
|
|
|
target varchar(64) NOT NULL,
|
|
|
|
primary key(id)
|
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
2008-06-15 00:25:47 +00:00
|
|
|
CREATE TABLE ir_act_server (
|
|
|
|
primary key(id)
|
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
2011-06-30 11:51:34 +00:00
|
|
|
CREATE TABLE ir_act_client (
|
|
|
|
primary key(id)
|
|
|
|
)
|
|
|
|
INHERITS (ir_actions);
|
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
CREATE TABLE ir_ui_menu (
|
2008-06-17 20:17:23 +00:00
|
|
|
id serial NOT NULL,
|
|
|
|
parent_id int references ir_ui_menu on delete set null,
|
|
|
|
name varchar(64) DEFAULT ''::varchar NOT NULL,
|
|
|
|
icon varchar(64) DEFAULT ''::varchar,
|
|
|
|
primary key (id)
|
2006-12-07 13:41:40 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
select setval('ir_ui_menu_id_seq', 2);
|
|
|
|
|
|
|
|
---------------------------------
|
|
|
|
-- Res users
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
-- level:
|
|
|
|
-- 0 RESTRICT TO USER
|
|
|
|
-- 1 RESTRICT TO GROUP
|
|
|
|
-- 2 PUBLIC
|
|
|
|
|
|
|
|
CREATE TABLE res_users (
|
|
|
|
id serial NOT NULL,
|
|
|
|
active boolean default True,
|
|
|
|
login varchar(64) NOT NULL UNIQUE,
|
2009-02-19 10:04:22 +00:00
|
|
|
password varchar(64) default null,
|
2010-03-29 08:56:00 +00:00
|
|
|
-- No FK references below, will be added later by ORM
|
|
|
|
-- (when the destination rows exist)
|
|
|
|
company_id int,
|
2012-08-10 14:05:49 +00:00
|
|
|
partner_id int,
|
2006-12-07 13:41:40 +00:00
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
alter table res_users add constraint res_users_login_uniq unique (login);
|
|
|
|
|
|
|
|
CREATE TABLE res_groups (
|
|
|
|
id serial NOT NULL,
|
2009-02-19 10:04:22 +00:00
|
|
|
name varchar(64) NOT NULL,
|
2006-12-07 13:41:40 +00:00
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE res_groups_users_rel (
|
2008-06-17 20:17:23 +00:00
|
|
|
uid integer NOT NULL references res_users on delete cascade,
|
2010-12-14 13:28:40 +00:00
|
|
|
gid integer NOT NULL references res_groups on delete cascade,
|
|
|
|
UNIQUE("uid","gid")
|
2006-12-07 13:41:40 +00:00
|
|
|
);
|
|
|
|
|
2009-03-15 18:52:19 +00:00
|
|
|
create index res_groups_users_rel_uid_idx on res_groups_users_rel (uid);
|
|
|
|
create index res_groups_users_rel_gid_idx on res_groups_users_rel (gid);
|
|
|
|
|
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
---------------------------------
|
|
|
|
-- Workflows
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
create table wkf
|
|
|
|
(
|
|
|
|
id serial,
|
|
|
|
name varchar(64),
|
|
|
|
osv varchar(64),
|
|
|
|
on_create bool default False,
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table wkf_activity
|
|
|
|
(
|
|
|
|
id serial,
|
|
|
|
wkf_id int references wkf on delete cascade,
|
|
|
|
subflow_id int references wkf on delete set null,
|
|
|
|
split_mode varchar(3) default 'XOR',
|
|
|
|
join_mode varchar(3) default 'XOR',
|
|
|
|
kind varchar(16) not null default 'dummy',
|
|
|
|
name varchar(64),
|
|
|
|
signal_send varchar(32) default null,
|
|
|
|
flow_start boolean default False,
|
|
|
|
flow_stop boolean default False,
|
2008-12-01 15:13:51 +00:00
|
|
|
action text default null,
|
2006-12-07 13:41:40 +00:00
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table wkf_transition
|
|
|
|
(
|
|
|
|
id serial,
|
|
|
|
act_from int references wkf_activity on delete cascade,
|
|
|
|
act_to int references wkf_activity on delete cascade,
|
|
|
|
condition varchar(128) default NULL,
|
|
|
|
|
|
|
|
trigger_type varchar(128) default NULL,
|
|
|
|
trigger_expr_id varchar(128) default NULL,
|
|
|
|
|
|
|
|
signal varchar(64) default null,
|
2010-10-13 21:53:40 +00:00
|
|
|
group_id int references res_groups on delete set null,
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table wkf_instance
|
|
|
|
(
|
|
|
|
id serial,
|
2007-12-31 13:31:38 +00:00
|
|
|
wkf_id int references wkf on delete restrict,
|
2006-12-07 13:41:40 +00:00
|
|
|
uid int default null,
|
|
|
|
res_id int not null,
|
|
|
|
res_type varchar(64) not null,
|
|
|
|
state varchar(32) not null default 'active',
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table wkf_workitem
|
|
|
|
(
|
|
|
|
id serial,
|
|
|
|
act_id int not null references wkf_activity on delete cascade,
|
|
|
|
inst_id int not null references wkf_instance on delete cascade,
|
|
|
|
subflow_id int references wkf_instance on delete cascade,
|
|
|
|
state varchar(64) default 'blocked',
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table wkf_witm_trans
|
|
|
|
(
|
|
|
|
trans_id int not null references wkf_transition on delete cascade,
|
|
|
|
inst_id int not null references wkf_instance on delete cascade
|
|
|
|
);
|
|
|
|
|
2009-03-15 18:55:32 +00:00
|
|
|
create index wkf_witm_trans_inst_idx on wkf_witm_trans (inst_id);
|
|
|
|
|
2006-12-07 13:41:40 +00:00
|
|
|
create table wkf_logs
|
|
|
|
(
|
|
|
|
id serial,
|
|
|
|
res_type varchar(128) not null,
|
|
|
|
res_id int not null,
|
|
|
|
uid int references res_users on delete set null,
|
|
|
|
act_id int references wkf_activity on delete set null,
|
|
|
|
time time not null,
|
|
|
|
info varchar(128) default NULL,
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
---------------------------------
|
|
|
|
-- Modules
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
CREATE TABLE ir_module_category (
|
|
|
|
id serial NOT NULL,
|
|
|
|
create_uid integer references res_users on delete set null,
|
|
|
|
create_date timestamp without time zone,
|
|
|
|
write_date timestamp without time zone,
|
|
|
|
write_uid integer references res_users on delete set null,
|
|
|
|
parent_id integer REFERENCES ir_module_category ON DELETE SET NULL,
|
|
|
|
name character varying(128) NOT NULL,
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE ir_module_module (
|
|
|
|
id serial NOT NULL,
|
|
|
|
create_uid integer references res_users on delete set null,
|
|
|
|
create_date timestamp without time zone,
|
|
|
|
write_date timestamp without time zone,
|
|
|
|
write_uid integer references res_users on delete set null,
|
|
|
|
website character varying(256),
|
2012-07-17 08:50:28 +00:00
|
|
|
summary character varying(256),
|
2006-12-07 13:41:40 +00:00
|
|
|
name character varying(128) NOT NULL,
|
|
|
|
author character varying(128),
|
|
|
|
url character varying(128),
|
2011-12-06 11:15:31 +00:00
|
|
|
icon character varying(64),
|
2006-12-07 13:41:40 +00:00
|
|
|
state character varying(16),
|
|
|
|
latest_version character varying(64),
|
|
|
|
shortdesc character varying(256),
|
2011-09-30 09:58:14 +00:00
|
|
|
complexity character varying(32),
|
2006-12-07 13:41:40 +00:00
|
|
|
category_id integer REFERENCES ir_module_category ON DELETE SET NULL,
|
|
|
|
description text,
|
2011-12-08 22:22:41 +00:00
|
|
|
application boolean default False,
|
2006-12-07 13:41:40 +00:00
|
|
|
demo boolean default False,
|
2010-09-28 07:52:57 +00:00
|
|
|
web boolean DEFAULT FALSE,
|
2010-11-27 03:20:14 +00:00
|
|
|
license character varying(32),
|
2012-01-07 04:17:45 +00:00
|
|
|
sequence integer DEFAULT 100,
|
2012-01-30 09:52:38 +00:00
|
|
|
auto_install boolean default False,
|
2006-12-07 13:41:40 +00:00
|
|
|
primary key(id)
|
|
|
|
);
|
2007-06-29 07:21:28 +00:00
|
|
|
ALTER TABLE ir_module_module add constraint name_uniq unique (name);
|
2006-12-07 13:41:40 +00:00
|
|
|
|
|
|
|
CREATE TABLE ir_module_module_dependency (
|
|
|
|
id serial NOT NULL,
|
|
|
|
create_uid integer references res_users on delete set null,
|
|
|
|
create_date timestamp without time zone,
|
|
|
|
write_date timestamp without time zone,
|
|
|
|
write_uid integer references res_users on delete set null,
|
|
|
|
name character varying(128),
|
|
|
|
version_pattern character varying(128) default NULL,
|
|
|
|
module_id integer REFERENCES ir_module_module ON DELETE cascade,
|
|
|
|
primary key(id)
|
|
|
|
);
|
|
|
|
|
2012-12-17 21:46:45 +00:00
|
|
|
CREATE TABLE res_partner (
|
2007-06-06 12:25:36 +00:00
|
|
|
id serial NOT NULL,
|
2012-12-17 21:46:45 +00:00
|
|
|
name character varying(128),
|
|
|
|
lang varchar(64),
|
|
|
|
company_id int,
|
2007-06-06 12:25:36 +00:00
|
|
|
primary key(id)
|
|
|
|
);
|
2008-06-17 20:17:23 +00:00
|
|
|
|
2012-12-17 21:46:45 +00:00
|
|
|
|
|
|
|
CREATE TABLE res_currency (
|
|
|
|
id serial PRIMARY KEY,
|
|
|
|
name VARCHAR(32) NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE res_company (
|
|
|
|
id serial PRIMARY KEY,
|
|
|
|
name character varying(128) not null,
|
|
|
|
parent_id integer references res_company on delete set null,
|
|
|
|
partner_id integer not null references res_partner,
|
|
|
|
currency_id integer not null references res_currency
|
|
|
|
|
|
|
|
);
|
|
|
|
|
2011-06-08 09:32:54 +00:00
|
|
|
CREATE TABLE res_lang (
|
|
|
|
id serial PRIMARY KEY,
|
|
|
|
name VARCHAR(64) NOT NULL UNIQUE,
|
|
|
|
code VARCHAR(16) NOT NULL UNIQUE
|
|
|
|
);
|
|
|
|
|
2008-06-17 20:17:23 +00:00
|
|
|
CREATE TABLE ir_model_data (
|
|
|
|
id serial NOT NULL,
|
|
|
|
create_uid integer,
|
|
|
|
create_date timestamp without time zone,
|
|
|
|
write_date timestamp without time zone,
|
|
|
|
write_uid integer,
|
|
|
|
noupdate boolean,
|
2013-11-08 13:02:08 +00:00
|
|
|
name varchar NOT NULL,
|
2008-06-17 20:17:23 +00:00
|
|
|
date_init timestamp without time zone,
|
|
|
|
date_update timestamp without time zone,
|
2013-11-08 13:02:08 +00:00
|
|
|
module varchar NOT NULL,
|
|
|
|
model varchar NOT NULL,
|
2008-06-17 20:17:23 +00:00
|
|
|
res_id integer, primary key(id)
|
|
|
|
);
|
|
|
|
|
2012-06-01 15:34:49 +00:00
|
|
|
-- Records foreign keys and constraints installed by a module (so they can be
|
2012-06-20 10:07:05 +00:00
|
|
|
-- 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).
|
2012-05-31 16:01:40 +00:00
|
|
|
CREATE TABLE ir_model_constraint (
|
|
|
|
id serial NOT NULL,
|
|
|
|
create_uid integer,
|
|
|
|
create_date timestamp without time zone,
|
|
|
|
write_date timestamp without time zone,
|
|
|
|
write_uid integer,
|
|
|
|
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,
|
2013-11-08 13:02:08 +00:00
|
|
|
name varchar NOT NULL
|
2012-05-31 16:01:40 +00:00
|
|
|
);
|
|
|
|
|
2012-06-01 15:34:49 +00:00
|
|
|
-- Records relation tables (i.e. implementing many2many) installed by a module
|
2012-06-20 10:07:05 +00:00
|
|
|
-- (so they can be removed when the module is uninstalled).
|
2012-06-01 15:34:49 +00:00
|
|
|
CREATE TABLE ir_model_relation (
|
|
|
|
id serial NOT NULL,
|
|
|
|
create_uid integer,
|
|
|
|
create_date timestamp without time zone,
|
|
|
|
write_date timestamp without time zone,
|
|
|
|
write_uid integer,
|
|
|
|
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,
|
2013-11-08 13:02:08 +00:00
|
|
|
name varchar NOT NULL
|
2012-12-17 21:46:45 +00:00
|
|
|
);
|
2012-06-01 15:34:49 +00:00
|
|
|
|
2008-07-14 13:53:01 +00:00
|
|
|
---------------------------------
|
|
|
|
-- Users
|
|
|
|
---------------------------------
|
2012-12-17 21:46:45 +00:00
|
|
|
insert into res_users (id,login,password,active,company_id,partner_id) VALUES (1,'admin','admin',true,1,1);
|
|
|
|
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('user_root','base','res.users',true,1);
|
|
|
|
|
|
|
|
insert into res_partner (id, name, lang, company_id) VALUES (1, 'Your Company', 'en_US', 1);
|
|
|
|
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('main_partner','base','res.partner',true,1);
|
2008-09-03 07:41:34 +00:00
|
|
|
|
2012-12-17 21:46:45 +00:00
|
|
|
insert into res_currency (id, name) VALUES (1, 'EUR');
|
|
|
|
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('EUR','base','res.currency',true,1);
|
2008-09-03 07:41:34 +00:00
|
|
|
|
2012-12-17 21:46:45 +00:00
|
|
|
insert into res_company (id, name, partner_id, currency_id) VALUES (1, 'Your Company', 1, 1);
|
|
|
|
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('main_company','base','res.company',true,1);
|
2008-09-03 07:41:34 +00:00
|
|
|
|
2012-12-17 21:46:45 +00:00
|
|
|
select setval('res_company_id_seq', 2);
|
2008-09-02 21:31:44 +00:00
|
|
|
select setval('res_users_id_seq', 2);
|
2012-12-17 21:46:45 +00:00
|
|
|
select setval('res_partner_id_seq', 2);
|
2013-04-26 14:51:13 +00:00
|
|
|
select setval('res_currency_id_seq', 2);
|