[IMP] base, rng: allowed name attribute on separator tag
[odoo/odoo.git] / openerp / addons / base / base.sql
1 -------------------------------------------------------------------------
2 -- Pure SQL
3 -------------------------------------------------------------------------
4
5 -------------------------------------------------------------------------
6 -- IR dictionary
7 -------------------------------------------------------------------------
8
9 create table ir_values
10 (
11     id serial,
12     name varchar(128) not null,
13     key varchar(128) not null,
14     key2 varchar(256) not null,
15     model varchar(128) not null,
16     value text,
17     meta text default NULL,
18     res_id integer default null,
19     primary key (id)
20 );
21
22 -------------------------------------------------------------------------
23 -- Modules Description
24 -------------------------------------------------------------------------
25
26 CREATE TABLE ir_model (
27   id serial,
28   model varchar(64) DEFAULT ''::varchar NOT NULL,
29   name varchar(64),
30   state varchar(16),
31   info text,
32   primary key(id)
33 );
34
35 CREATE TABLE ir_model_fields (
36   id serial,
37   model varchar(64) DEFAULT ''::varchar NOT NULL,
38   model_id int references ir_model on delete cascade,
39   name varchar(64) DEFAULT ''::varchar NOT NULL,
40   relation varchar(64),
41   select_level varchar(4),
42   field_description varchar(256),
43   ttype varchar(64),
44   state varchar(64) default 'base',
45   view_load boolean,
46   relate boolean default False,
47   relation_field varchar(128),
48   translate boolean default False,
49   primary key(id)
50 );
51
52
53 -------------------------------------------------------------------------
54 -- Actions
55 -------------------------------------------------------------------------
56
57 CREATE TABLE ir_actions (
58     id serial NOT NULL,
59     name varchar(64) DEFAULT ''::varchar NOT NULL,
60     "type" varchar(32) DEFAULT 'window'::varchar NOT NULL,
61     usage varchar(32) DEFAULT null,
62     primary key(id)
63 );
64
65 CREATE TABLE ir_act_window (
66     view_id integer,
67     res_model varchar(64),
68     view_type varchar(16),
69     "domain" varchar(250),
70     primary key(id)
71 )
72 INHERITS (ir_actions);
73
74 CREATE TABLE ir_act_report_xml (
75     model varchar(64) NOT NULL,
76     report_name varchar(64) NOT NULL,
77     report_xsl varchar(256),
78     report_xml varchar(256),
79     auto boolean default true,
80     primary key(id)
81 )
82 INHERITS (ir_actions);
83
84 create table ir_act_report_custom (
85     report_id int,
86 --  report_id int references ir_report_custom
87     primary key(id)
88 )
89 INHERITS (ir_actions);
90
91 CREATE TABLE ir_act_wizard (
92     wiz_name varchar(64) NOT NULL,
93     primary key(id)
94 )
95 INHERITS (ir_actions);
96
97 CREATE TABLE ir_act_url (
98     url text NOT NULL,
99     target varchar(64) NOT NULL,
100     primary key(id)
101 )
102 INHERITS (ir_actions);
103
104 CREATE TABLE ir_act_server (
105     primary key(id)
106 )
107 INHERITS (ir_actions);
108
109
110 CREATE TABLE ir_ui_view (
111     id serial NOT NULL,
112     name varchar(64) DEFAULT ''::varchar NOT NULL,
113     model varchar(64) DEFAULT ''::varchar NOT NULL,
114     "type" varchar(64) DEFAULT 'form'::varchar NOT NULL,
115     arch text NOT NULL,
116     field_parent varchar(64),
117     priority integer DEFAULT 5 NOT NULL,
118     primary key(id)
119 );
120
121 CREATE TABLE ir_ui_menu (
122     id serial NOT NULL,
123     parent_id int references ir_ui_menu on delete set null,
124     name varchar(64) DEFAULT ''::varchar NOT NULL,
125     icon varchar(64) DEFAULT ''::varchar,
126     primary key (id)
127 );
128
129 select setval('ir_ui_menu_id_seq', 2);
130
131 ---------------------------------
132 -- Res users
133 ---------------------------------
134
135 -- level:
136 --   0  RESTRICT TO USER
137 --   1  RESTRICT TO GROUP
138 --   2  PUBLIC
139
140 CREATE TABLE res_users (
141     id serial NOT NULL,
142     name varchar(64) not null,
143     active boolean default True,
144     login varchar(64) NOT NULL UNIQUE,
145     password varchar(64) default null,
146     email varchar(64) default null,
147     context_tz varchar(64) default null,
148     signature text,
149     context_lang varchar(64) default '',
150     -- No FK references below, will be added later by ORM
151     -- (when the destination rows exist)
152     company_id int,
153     primary key(id)
154 );
155 alter table res_users add constraint res_users_login_uniq unique (login);
156
157 CREATE TABLE res_groups (
158     id serial NOT NULL,
159     name varchar(64) NOT NULL,
160     primary key(id)
161 );
162
163 CREATE TABLE res_groups_users_rel (
164     uid integer NOT NULL references res_users on delete cascade,
165     gid integer NOT NULL references res_groups on delete cascade,
166     UNIQUE("uid","gid")
167 );
168
169 create index res_groups_users_rel_uid_idx on res_groups_users_rel (uid);
170 create index res_groups_users_rel_gid_idx on res_groups_users_rel (gid);
171
172
173 ---------------------------------
174 -- Workflows
175 ---------------------------------
176
177 create table wkf
178 (
179     id serial,
180     name varchar(64),
181     osv varchar(64),
182     on_create bool default False,
183     primary key(id)
184 );
185
186 create table wkf_activity
187 (
188     id serial,
189     wkf_id int references wkf on delete cascade,
190     subflow_id int references wkf on delete set null,
191     split_mode varchar(3) default 'XOR',
192     join_mode varchar(3) default 'XOR',
193     kind varchar(16) not null default 'dummy',
194     name varchar(64),
195     signal_send varchar(32) default null,
196     flow_start boolean default False,
197     flow_stop boolean default False,
198     action text default null,
199     primary key(id)
200 );
201
202 create table wkf_transition
203 (
204     id serial,
205     act_from int references wkf_activity on delete cascade,
206     act_to int references wkf_activity on delete cascade,
207     condition varchar(128) default NULL,
208
209     trigger_type varchar(128) default NULL,
210     trigger_expr_id varchar(128) default NULL,
211
212     signal varchar(64) default null,
213     group_id int references res_groups on delete set null,
214
215     primary key(id)
216 );
217
218 create table wkf_instance
219 (
220     id serial,
221     wkf_id int references wkf on delete restrict,
222     uid int default null,
223     res_id int not null,
224     res_type varchar(64) not null,
225     state varchar(32) not null default 'active',
226     primary key(id)
227 );
228
229 create table wkf_workitem
230 (
231     id serial,
232     act_id int not null references wkf_activity on delete cascade,
233     inst_id int not null references wkf_instance on delete cascade,
234     subflow_id int references wkf_instance on delete cascade,
235     state varchar(64) default 'blocked',
236     primary key(id)
237 );
238
239 create table wkf_witm_trans
240 (
241     trans_id int not null references wkf_transition on delete cascade,
242     inst_id int not null references wkf_instance on delete cascade
243 );
244
245 create index wkf_witm_trans_inst_idx on wkf_witm_trans (inst_id);
246
247 create table wkf_logs
248 (
249     id serial,
250     res_type varchar(128) not null,
251     res_id int not null,
252     uid int references res_users on delete set null,
253     act_id int references wkf_activity on delete set null,
254     time time not null,
255     info varchar(128) default NULL,
256     primary key(id)
257 );
258
259 ---------------------------------
260 -- Modules
261 ---------------------------------
262
263 CREATE TABLE ir_module_category (
264     id serial NOT NULL,
265     create_uid integer references res_users on delete set null,
266     create_date timestamp without time zone,
267     write_date timestamp without time zone,
268     write_uid integer references res_users on delete set null,
269     parent_id integer REFERENCES ir_module_category ON DELETE SET NULL,
270     name character varying(128) NOT NULL,
271     primary key(id)
272 );
273
274
275 CREATE TABLE ir_module_module (
276     id serial NOT NULL,
277     create_uid integer references res_users on delete set null,
278     create_date timestamp without time zone,
279     write_date timestamp without time zone,
280     write_uid integer references res_users on delete set null,
281     website character varying(256),
282     name character varying(128) NOT NULL,
283     author character varying(128),
284     url character varying(128),
285     state character varying(16),
286     latest_version character varying(64),
287     shortdesc character varying(256),
288     category_id integer REFERENCES ir_module_category ON DELETE SET NULL,
289     certificate character varying(64),
290     description text,
291     demo boolean default False,
292     web boolean DEFAULT FALSE,
293     license character varying(32),
294     primary key(id)
295 );
296 ALTER TABLE ir_module_module add constraint name_uniq unique (name);
297
298 CREATE TABLE ir_module_module_dependency (
299     id serial NOT NULL,
300     create_uid integer references res_users on delete set null,
301     create_date timestamp without time zone,
302     write_date timestamp without time zone,
303     write_uid integer references res_users on delete set null,
304     name character varying(128),
305     version_pattern character varying(128) default NULL,
306     module_id integer REFERENCES ir_module_module ON DELETE cascade,
307     primary key(id)
308 );
309
310 CREATE TABLE res_company (
311     id serial NOT NULL,
312     name character varying(64) not null,
313     parent_id integer references res_company on delete set null,
314     primary key(id)
315 );
316
317 CREATE TABLE ir_model_data (
318     id serial NOT NULL,
319     create_uid integer,
320     create_date timestamp without time zone,
321     write_date timestamp without time zone,
322     write_uid integer,
323     noupdate boolean,
324     name character varying(128) NOT NULL,
325     date_init timestamp without time zone,
326     date_update timestamp without time zone,
327     module character varying(64) NOT NULL,
328     model character varying(64) NOT NULL,
329     res_id integer, primary key(id)
330 );
331
332 ---------------------------------
333 -- Users
334 ---------------------------------
335
336 insert into res_users (id,login,password,name,active,company_id,context_lang) values (1,'admin','admin','Administrator',True,1,'en_US');
337 insert into ir_model_data (name,module,model,noupdate,res_id) values ('user_root','base','res.users',True,1);
338
339 -- Compatibility purpose, to remove V6.0
340 insert into ir_model_data (name,module,model,noupdate,res_id) values ('user_admin','base','res.users',True,1);
341
342 select setval('res_users_id_seq', 2);