diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 6a31fa3e745..127091b7963 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -498,3 +498,29 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663); ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL; + + +CREATE TABLE llx_mrp_production( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_mo integer NOT NULL, + position integer NOT NULL DEFAULT 0, + fk_product integer NOT NULL, + fk_warehouse integer, + qty integer NOT NULL DEFAULT 1, + batch varchar(30), + role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation) + fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce' + fk_stock_movement integer, -- id of stock movement when movements are validated + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14) +) ENGINE=innodb; + +ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_mo FOREIGN KEY (fk_mo) REFERENCES llx_mrp_mo (rowid); +ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); +ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement FOREIGN KEY (fk_stock_movement) REFERENCES llx_stock_mouvement (rowid); + +ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo); + diff --git a/htdocs/install/mysql/tables/llx_mrp_production.key.sql b/htdocs/install/mysql/tables/llx_mrp_production.key.sql new file mode 100644 index 00000000000..d77ef297e82 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_mrp_production.key.sql @@ -0,0 +1,21 @@ +-- Copyright (C) 2019 Laurent Destailleur +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + +ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_mo FOREIGN KEY (fk_mo) REFERENCES llx_mrp_mo (rowid); +ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); +ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement FOREIGN KEY (fk_stock_movement) REFERENCES llx_stock_mouvement (rowid); + +ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo); + diff --git a/htdocs/install/mysql/tables/llx_mrp_production.sql b/htdocs/install/mysql/tables/llx_mrp_production.sql new file mode 100644 index 00000000000..275acde6aef --- /dev/null +++ b/htdocs/install/mysql/tables/llx_mrp_production.sql @@ -0,0 +1,34 @@ +-- Copyright (C) 2019 Laurent Destailleur +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see http://www.gnu.org/licenses/. + + +CREATE TABLE llx_mrp_production( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_mo integer NOT NULL, + position integer NOT NULL DEFAULT 0, + fk_product integer NOT NULL, + fk_warehouse integer, + qty integer NOT NULL DEFAULT 1, + batch varchar(30), + role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation) + fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce' + fk_stock_movement integer, -- id of stock movement when movements are validated + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14) +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_product_batch.sql b/htdocs/install/mysql/tables/llx_product_batch.sql index 70b7d024398..ba8b7ff59e4 100644 --- a/htdocs/install/mysql/tables/llx_product_batch.sql +++ b/htdocs/install/mysql/tables/llx_product_batch.sql @@ -17,6 +17,7 @@ -- -- This table is dedicated to store detail (lots/serial) of a stock -- ============================================================================ + CREATE TABLE llx_product_batch ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp,