~tempo-openerp/+junk/loewert-report-name

« back to all changes in this revision

Viewing changes to addons/base/base.sql

  • Committer: jbe at tempo-consulting
  • Date: 2013-08-21 08:48:11 UTC
  • Revision ID: jbe@tempo-consulting.fr-20130821084811-913uo4l7b5ayxq8m
[NEW] Création de la branche trunk Loewert

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
ALTER TABLE ir_model_fields ADD column serialization_field_id int references ir_model_fields on delete cascade;
 
53
 
 
54
 
 
55
-------------------------------------------------------------------------
 
56
-- Actions
 
57
-------------------------------------------------------------------------
 
58
 
 
59
CREATE TABLE ir_actions (
 
60
    id serial NOT NULL,
 
61
    name varchar(64) DEFAULT ''::varchar NOT NULL,
 
62
    "type" varchar(32) NOT NULL,
 
63
    usage varchar(32) DEFAULT null,
 
64
    primary key(id)
 
65
);
 
66
 
 
67
CREATE TABLE ir_act_window (
 
68
    view_id integer,
 
69
    res_model varchar(64),
 
70
    view_type varchar(16),
 
71
    "domain" varchar(250),
 
72
    primary key(id)
 
73
)
 
74
INHERITS (ir_actions);
 
75
 
 
76
CREATE TABLE ir_act_report_xml (
 
77
    model varchar(64) NOT NULL,
 
78
    report_name varchar(64) NOT NULL,
 
79
    report_xsl varchar(256),
 
80
    report_xml varchar(256),
 
81
    auto boolean default true,
 
82
    primary key(id)
 
83
)
 
84
INHERITS (ir_actions);
 
85
 
 
86
create table ir_act_report_custom (
 
87
    report_id int,
 
88
--  report_id int references ir_report_custom
 
89
    primary key(id)
 
90
)
 
91
INHERITS (ir_actions);
 
92
 
 
93
CREATE TABLE ir_act_wizard (
 
94
    wiz_name varchar(64) NOT NULL,
 
95
    primary key(id)
 
96
)
 
97
INHERITS (ir_actions);
 
98
 
 
99
CREATE TABLE ir_act_url (
 
100
    url text NOT NULL,
 
101
    target varchar(64) NOT NULL,
 
102
    primary key(id)
 
103
)
 
104
INHERITS (ir_actions);
 
105
 
 
106
CREATE TABLE ir_act_server (
 
107
    primary key(id)
 
108
)
 
109
INHERITS (ir_actions);
 
110
 
 
111
CREATE TABLE ir_act_client (
 
112
    primary key(id)
 
113
)
 
114
INHERITS (ir_actions);
 
115
 
 
116
 
 
117
CREATE TABLE ir_ui_view (
 
118
    id serial NOT NULL,
 
119
    name varchar(64) DEFAULT ''::varchar NOT NULL,
 
120
    model varchar(64) DEFAULT ''::varchar NOT NULL,
 
121
    "type" varchar(64) DEFAULT 'form'::varchar NOT NULL,
 
122
    arch text NOT NULL,
 
123
    field_parent varchar(64),
 
124
    priority integer DEFAULT 5 NOT NULL,
 
125
    primary key(id)
 
126
);
 
127
 
 
128
CREATE TABLE ir_ui_menu (
 
129
    id serial NOT NULL,
 
130
    parent_id int references ir_ui_menu on delete set null,
 
131
    name varchar(64) DEFAULT ''::varchar NOT NULL,
 
132
    icon varchar(64) DEFAULT ''::varchar,
 
133
    primary key (id)
 
134
);
 
135
 
 
136
select setval('ir_ui_menu_id_seq', 2);
 
137
 
 
138
---------------------------------
 
139
-- Res users
 
140
---------------------------------
 
141
 
 
142
-- level:
 
143
--   0  RESTRICT TO USER
 
144
--   1  RESTRICT TO GROUP
 
145
--   2  PUBLIC
 
146
 
 
147
CREATE TABLE res_users (
 
148
    id serial NOT NULL,
 
149
    active boolean default True,
 
150
    login varchar(64) NOT NULL UNIQUE,
 
151
    password varchar(64) default null,
 
152
    -- No FK references below, will be added later by ORM
 
153
    -- (when the destination rows exist)
 
154
    company_id int,
 
155
    partner_id int,
 
156
    primary key(id)
 
157
);
 
158
alter table res_users add constraint res_users_login_uniq unique (login);
 
159
 
 
160
CREATE TABLE res_groups (
 
161
    id serial NOT NULL,
 
162
    name varchar(64) NOT NULL,
 
163
    primary key(id)
 
164
);
 
165
 
 
166
CREATE TABLE res_groups_users_rel (
 
167
    uid integer NOT NULL references res_users on delete cascade,
 
168
    gid integer NOT NULL references res_groups on delete cascade,
 
169
    UNIQUE("uid","gid")
 
170
);
 
171
 
 
172
create index res_groups_users_rel_uid_idx on res_groups_users_rel (uid);
 
173
create index res_groups_users_rel_gid_idx on res_groups_users_rel (gid);
 
174
 
 
175
 
 
176
---------------------------------
 
177
-- Workflows
 
178
---------------------------------
 
179
 
 
180
create table wkf
 
181
(
 
182
    id serial,
 
183
    name varchar(64),
 
184
    osv varchar(64),
 
185
    on_create bool default False,
 
186
    primary key(id)
 
187
);
 
188
 
 
189
create table wkf_activity
 
190
(
 
191
    id serial,
 
192
    wkf_id int references wkf on delete cascade,
 
193
    subflow_id int references wkf on delete set null,
 
194
    split_mode varchar(3) default 'XOR',
 
195
    join_mode varchar(3) default 'XOR',
 
196
    kind varchar(16) not null default 'dummy',
 
197
    name varchar(64),
 
198
    signal_send varchar(32) default null,
 
199
    flow_start boolean default False,
 
200
    flow_stop boolean default False,
 
201
    action text default null,
 
202
    primary key(id)
 
203
);
 
204
 
 
205
create table wkf_transition
 
206
(
 
207
    id serial,
 
208
    act_from int references wkf_activity on delete cascade,
 
209
    act_to int references wkf_activity on delete cascade,
 
210
    condition varchar(128) default NULL,
 
211
 
 
212
    trigger_type varchar(128) default NULL,
 
213
    trigger_expr_id varchar(128) default NULL,
 
214
 
 
215
    signal varchar(64) default null,
 
216
    group_id int references res_groups on delete set null,
 
217
 
 
218
    primary key(id)
 
219
);
 
220
 
 
221
create table wkf_instance
 
222
(
 
223
    id serial,
 
224
    wkf_id int references wkf on delete restrict,
 
225
    uid int default null,
 
226
    res_id int not null,
 
227
    res_type varchar(64) not null,
 
228
    state varchar(32) not null default 'active',
 
229
    primary key(id)
 
230
);
 
231
 
 
232
create table wkf_workitem
 
233
(
 
234
    id serial,
 
235
    act_id int not null references wkf_activity on delete cascade,
 
236
    inst_id int not null references wkf_instance on delete cascade,
 
237
    subflow_id int references wkf_instance on delete cascade,
 
238
    state varchar(64) default 'blocked',
 
239
    primary key(id)
 
240
);
 
241
 
 
242
create table wkf_witm_trans
 
243
(
 
244
    trans_id int not null references wkf_transition on delete cascade,
 
245
    inst_id int not null references wkf_instance on delete cascade
 
246
);
 
247
 
 
248
create index wkf_witm_trans_inst_idx on wkf_witm_trans (inst_id);
 
249
 
 
250
create table wkf_logs
 
251
(
 
252
    id serial,
 
253
    res_type varchar(128) not null,
 
254
    res_id int not null,
 
255
    uid int references res_users on delete set null,
 
256
    act_id int references wkf_activity on delete set null,
 
257
    time time not null,
 
258
    info varchar(128) default NULL,
 
259
    primary key(id)
 
260
);
 
261
 
 
262
---------------------------------
 
263
-- Modules
 
264
---------------------------------
 
265
 
 
266
CREATE TABLE ir_module_category (
 
267
    id serial NOT NULL,
 
268
    create_uid integer references res_users on delete set null,
 
269
    create_date timestamp without time zone,
 
270
    write_date timestamp without time zone,
 
271
    write_uid integer references res_users on delete set null,
 
272
    parent_id integer REFERENCES ir_module_category ON DELETE SET NULL,
 
273
    name character varying(128) NOT NULL,
 
274
    primary key(id)
 
275
);
 
276
 
 
277
 
 
278
CREATE TABLE ir_module_module (
 
279
    id serial NOT NULL,
 
280
    create_uid integer references res_users on delete set null,
 
281
    create_date timestamp without time zone,
 
282
    write_date timestamp without time zone,
 
283
    write_uid integer references res_users on delete set null,
 
284
    website character varying(256),
 
285
    summary character varying(256),
 
286
    name character varying(128) NOT NULL,
 
287
    author character varying(128),
 
288
    url character varying(128),
 
289
    icon character varying(64),
 
290
    state character varying(16),
 
291
    latest_version character varying(64),
 
292
    shortdesc character varying(256),
 
293
    complexity character varying(32),
 
294
    category_id integer REFERENCES ir_module_category ON DELETE SET NULL,
 
295
    description text,
 
296
    application boolean default False,
 
297
    demo boolean default False,
 
298
    web boolean DEFAULT FALSE,
 
299
    license character varying(32),
 
300
    sequence integer DEFAULT 100,
 
301
    auto_install boolean default False,
 
302
    primary key(id)
 
303
);
 
304
ALTER TABLE ir_module_module add constraint name_uniq unique (name);
 
305
 
 
306
CREATE TABLE ir_module_module_dependency (
 
307
    id serial NOT NULL,
 
308
    create_uid integer references res_users on delete set null,
 
309
    create_date timestamp without time zone,
 
310
    write_date timestamp without time zone,
 
311
    write_uid integer references res_users on delete set null,
 
312
    name character varying(128),
 
313
    version_pattern character varying(128) default NULL,
 
314
    module_id integer REFERENCES ir_module_module ON DELETE cascade,
 
315
    primary key(id)
 
316
);
 
317
 
 
318
CREATE TABLE res_partner (
 
319
    id serial NOT NULL,
 
320
    name character varying(128),
 
321
    lang varchar(64),
 
322
    company_id int,
 
323
    primary key(id)
 
324
);
 
325
 
 
326
 
 
327
CREATE TABLE res_currency (
 
328
    id serial PRIMARY KEY,
 
329
    name VARCHAR(32) NOT NULL
 
330
);
 
331
 
 
332
CREATE TABLE res_company (
 
333
    id serial PRIMARY KEY,
 
334
    name character varying(128) not null,
 
335
    parent_id integer references res_company on delete set null,
 
336
    partner_id integer not null references res_partner,
 
337
    currency_id integer not null references res_currency
 
338
    
 
339
);
 
340
 
 
341
CREATE TABLE res_lang (
 
342
    id serial PRIMARY KEY,
 
343
    name VARCHAR(64) NOT NULL UNIQUE,
 
344
    code VARCHAR(16) NOT NULL UNIQUE
 
345
);
 
346
 
 
347
CREATE TABLE ir_model_data (
 
348
    id serial NOT NULL,
 
349
    create_uid integer,
 
350
    create_date timestamp without time zone,
 
351
    write_date timestamp without time zone,
 
352
    write_uid integer,
 
353
    noupdate boolean,
 
354
    name character varying(128) NOT NULL,
 
355
    date_init timestamp without time zone,
 
356
    date_update timestamp without time zone,
 
357
    module character varying(64) NOT NULL,
 
358
    model character varying(64) NOT NULL,
 
359
    res_id integer, primary key(id)
 
360
);
 
361
 
 
362
-- Records foreign keys and constraints installed by a module (so they can be
 
363
-- removed when the module is uninstalled):
 
364
--   - for a foreign key: type is 'f',
 
365
--   - for a constraint: type is 'u' (this is the convention PostgreSQL uses).
 
366
CREATE TABLE ir_model_constraint (
 
367
    id serial NOT NULL,
 
368
    create_uid integer,
 
369
    create_date timestamp without time zone,
 
370
    write_date timestamp without time zone,
 
371
    write_uid integer,
 
372
    date_init timestamp without time zone,
 
373
    date_update timestamp without time zone,
 
374
    module integer NOT NULL references ir_module_module on delete restrict,
 
375
    model integer NOT NULL references ir_model on delete restrict,
 
376
    type character varying(1) NOT NULL,
 
377
    name character varying(128) NOT NULL
 
378
);
 
379
 
 
380
-- Records relation tables (i.e. implementing many2many) installed by a module
 
381
-- (so they can be removed when the module is uninstalled).
 
382
CREATE TABLE ir_model_relation (
 
383
    id serial NOT NULL,
 
384
    create_uid integer,
 
385
    create_date timestamp without time zone,
 
386
    write_date timestamp without time zone,
 
387
    write_uid integer,
 
388
    date_init timestamp without time zone,
 
389
    date_update timestamp without time zone,
 
390
    module integer NOT NULL references ir_module_module on delete restrict,
 
391
    model integer NOT NULL references ir_model on delete restrict,
 
392
    name character varying(128) NOT NULL
 
393
);  
 
394
 
 
395
---------------------------------
 
396
-- Users
 
397
---------------------------------
 
398
insert into res_users (id,login,password,active,company_id,partner_id) VALUES (1,'admin','admin',true,1,1);
 
399
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('user_root','base','res.users',true,1);
 
400
 
 
401
insert into res_partner (id, name, lang, company_id) VALUES (1, 'Your Company', 'en_US', 1);
 
402
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('main_partner','base','res.partner',true,1);
 
403
 
 
404
insert into res_currency (id, name) VALUES (1, 'EUR');
 
405
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('EUR','base','res.currency',true,1);
 
406
 
 
407
insert into res_company (id, name, partner_id, currency_id) VALUES (1, 'Your Company', 1, 1);
 
408
insert into ir_model_data (name,module,model,noupdate,res_id) VALUES ('main_company','base','res.company',true,1);
 
409
 
 
410
select setval('res_company_id_seq', 2);
 
411
select setval('res_users_id_seq', 2);
 
412
select setval('res_partner_id_seq', 2);
 
413
select setval('res_currency_id_seq', 2);
 
 
b'\\ No newline at end of file'