summaryrefslogtreecommitdiff
path: root/openerp/addons/base/base.sql
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2012-12-17 22:46:45 +0100
committerOlivier Dony <odo@openerp.com>2012-12-17 22:46:45 +0100
commit9f77d2e2f4b580e2fb07bc044c875dfd30008f44 (patch)
tree7839e0e8ced7e6b60048769028219162d7f8927a /openerp/addons/base/base.sql
parentf827de704938686c5788c9041e9fe7ad1d268227 (diff)
[FIX] orm,registry: properly check m2o FKs during model update + fix some models `auto_init`ed multiple times
The case where no constraint existed at all was not working, and after fixing it, the ORM started to re-create the same constraints multiple times for some modules. This was for models that are split within a module (such as res.users in base, which is made of several small classes): all the partial models were going through _auto_init instead of only the final one - doing useless extra work. Unfortunately establishing the FK happens before the XML data files are loaded, so a number of FK and NOT NULL constraints failed to apply due to missing tables/records. base.sql had to be extended a bit to cover these cases in a minimalist fashion bzr revid: odo@openerp.com-20121217214645-av9n003yzterhujw
Diffstat (limited to 'openerp/addons/base/base.sql')
-rw-r--r--openerp/addons/base/base.sql41
1 files changed, 32 insertions, 9 deletions
diff --git a/openerp/addons/base/base.sql b/openerp/addons/base/base.sql
index 3fa847ce23c..b1ddb2eec70 100644
--- a/openerp/addons/base/base.sql
+++ b/openerp/addons/base/base.sql
@@ -149,7 +149,6 @@ CREATE TABLE res_users (
active boolean default True,
login varchar(64) NOT NULL UNIQUE,
password varchar(64) default null,
- lang varchar(64) default '',
-- No FK references below, will be added later by ORM
-- (when the destination rows exist)
company_id int,
@@ -316,13 +315,29 @@ CREATE TABLE ir_module_module_dependency (
primary key(id)
);
-CREATE TABLE res_company (
+CREATE TABLE res_partner (
id serial NOT NULL,
- name character varying(64) not null,
- parent_id integer references res_company on delete set null,
+ name character varying(128),
+ lang varchar(64),
+ company_id int,
primary key(id)
);
+
+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
+
+);
+
CREATE TABLE res_lang (
id serial PRIMARY KEY,
name VARCHAR(64) NOT NULL UNIQUE,
@@ -375,16 +390,24 @@ CREATE TABLE ir_model_relation (
module integer NOT NULL references ir_module_module on delete restrict,
model integer NOT NULL references ir_model on delete restrict,
name character varying(128) NOT NULL
-);
+);
---------------------------------
-- Users
---------------------------------
+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);
-insert into res_users (id,login,password,active,company_id,partner_id,lang) values (1,'admin','admin',True,1,1,'en_US');
-insert into ir_model_data (name,module,model,noupdate,res_id) values ('user_root','base','res.users',True,1);
+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);
--- Compatibility purpose, to remove V6.0
-insert into ir_model_data (name,module,model,noupdate,res_id) values ('user_admin','base','res.users',True,1);
+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);
+select setval('res_company_id_seq', 2);
select setval('res_users_id_seq', 2);
+select setval('res_partner_id_seq', 2);
+select setval('res_currency_id_seq', 2); \ No newline at end of file