Debug SQL

This commit is contained in:
ldestailleur
2025-03-19 11:31:06 +01:00
parent 81aca843ba
commit debf628c60
3 changed files with 8 additions and 8 deletions

View File

@@ -208,10 +208,9 @@ DELETE FROM llx_const WHERE name = 'STOCK_ALLOW_NEGATIVE_TRANSFER' AND value = 1
ALTER TABLE llx_links ADD COLUMN share varchar(128) NULL AFTER objectid;
ALTER TABLE llx_links ADD COLUMN share_pass varchar(32) NULL AFTER share;
-- Dispatcher for virtual products
ALTER TABLE llx_expeditiondet ADD COLUMN fk_parent integer NULL AFTER fk_product;
ALTER TABLE llx_expeditiondet ADD COLUMN fk_parent integer NULL AFTER fk_product; -- for sublines
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_parent (fk_parent);
ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_parent FOREIGN KEY (fk_parent) REFERENCES llx_expeditiondet (rowid);
--ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
--ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_parent FOREIGN KEY (fk_parent) REFERENCES llx_expeditiondet (rowid);
UPDATE llx_expeditiondet as ed LEFT JOIN llx_commandedet ON ed.fk_elementdet = llx_commandedet.rowid SET ed.fk_product = llx_commandedet.fk_product WHERE ed.fk_product IS NULL AND ed.element_type = 'commande';
UPDATE llx_expeditiondet as ed SET ed.fk_product = (SELECT cd.fk_product FROM llx_commandedet as cd WHERE cd.rowid = ed.fk_elementdet AND ed.element_type = 'commande') AND ed.fk_product IS NULL;

View File

@@ -22,6 +22,7 @@ ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expe
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_elementdet (fk_elementdet);
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_product (fk_product);
ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_parent (fk_parent);
ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid);
ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_parent FOREIGN KEY (fk_parent) REFERENCES llx_expeditiondet (rowid);
--ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid);
--ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_parent FOREIGN KEY (fk_parent) REFERENCES llx_expeditiondet (rowid);

View File

@@ -26,7 +26,7 @@ create table llx_expeditiondet
fk_element integer, -- ID of main source object
fk_elementdet integer, -- ID of line of source object (proposal, sale order)
element_type varchar(50) DEFAULT 'commande' NOT NULL, -- Type of source object ('commande', ...)
fk_product integer, -- ID of product. If empy, you can retreive it using fk_element/element_type link
fk_product integer, -- ID of product. If empy, you can retreive it using fk_element/element_type link.
fk_parent integer, -- ID of parent line
qty real, -- Quantity
fk_unit integer, -- ID of unit code