From 7c4942b7bede6b3ff215d49c3f0ac86546ccdfb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2019 20:14:33 +0100 Subject: [PATCH] Fix debug BOM/MO --- htdocs/bom/bom_card.php | 14 ++++++++++---- htdocs/bom/class/bom.class.php | 3 +-- htdocs/core/modules/modBom.class.php | 4 ++-- htdocs/core/modules/modMrp.class.php | 4 ++-- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_bom_bom.sql | 3 ++- htdocs/install/mysql/tables/llx_mrp_mo.sql | 3 ++- .../template/class/myobject.class.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 5 ++++- 9 files changed, 27 insertions(+), 14 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 1fbce9d2824..941eb621e7c 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -111,6 +111,12 @@ if (empty($reshook)) // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + // Action to move up and down lines of object + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; + + // Action to build doc + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Actions to send emails $trigger_name='BOM_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_BOM_TO'; @@ -145,8 +151,8 @@ if (empty($reshook)) $bomline->fk_bom = $id; $bomline->fk_product = $idprod; $bomline->qty = $qty; - $bomline->qty_frozen = $qty_frozen; - $bomline->disable_stock_change = $disable_stock_change; + $bomline->qty_frozen = (int) $qty_frozen; + $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; $result = $bomline->create($user); @@ -183,8 +189,8 @@ if (empty($reshook)) $bomline = new BOMLine($db); $bomline->fetch($lineid); $bomline->qty = $qty; - $bomline->qty_frozen = $qty_frozen; - $bomline->disable_stock_change = $disable_stock_change; + $bomline->qty_frozen = (int) $qty_frozen; + $bomline->disable_stock_change = (int) $disable_stock_change; $bomline->efficiency = $efficiency; $result = $bomline->update($user); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 65f619cb0b2..040f194e81f 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -937,8 +937,7 @@ class BOM extends CommonObject $modelpath = "core/modules/bom/doc/"; - //return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - return 1; + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } /** diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 47daf430873..1df8d8ad48f 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -356,8 +356,8 @@ class modBom extends DolibarrModules } $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")" + //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'bom' AND entity = ".$conf->entity, + //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'bom', ".$conf->entity.")" ); return $this->_init($sql, $options); diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php index 43908b85164..e66814d5fc1 100644 --- a/htdocs/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -352,8 +352,8 @@ class modMrp extends DolibarrModules } $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")" + //"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('standard')."' AND type = 'mo' AND entity = ".$conf->entity, + //"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('standard')."', 'mo', ".$conf->entity.")" ); return $this->_init($sql, $options); 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 6ac83f249ed..fcd7ede9bcc 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 @@ -436,6 +436,7 @@ CREATE TABLE llx_mrp_mo( tms timestamp, fk_user_creat integer NOT NULL, fk_user_modif integer, + model_pdf varchar(255), import_key varchar(14), status integer NOT NULL, fk_product integer NOT NULL, @@ -446,6 +447,8 @@ CREATE TABLE llx_mrp_mo( -- END MODULEBUILDER FIELDS ) ENGINE=innodb; +ALTER TABLE llx_bom_bom ADD COLUMN model_pdf varchar(255); +ALTER TABLE llx_mrp_mo ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); diff --git a/htdocs/install/mysql/tables/llx_bom_bom.sql b/htdocs/install/mysql/tables/llx_bom_bom.sql index d195dc4ec5d..f1e80d927f9 100644 --- a/htdocs/install/mysql/tables/llx_bom_bom.sql +++ b/htdocs/install/mysql/tables/llx_bom_bom.sql @@ -33,7 +33,8 @@ CREATE TABLE llx_bom_bom( fk_user_creat integer NOT NULL, fk_user_modif integer, fk_user_valid integer, - import_key varchar(14), + import_key varchar(14), + model_pdf varchar(255), status integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_mrp_mo.sql b/htdocs/install/mysql/tables/llx_mrp_mo.sql index 52a046191dc..19f48e27e8a 100644 --- a/htdocs/install/mysql/tables/llx_mrp_mo.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.sql @@ -29,7 +29,8 @@ CREATE TABLE llx_mrp_mo( tms timestamp, fk_user_creat integer NOT NULL, fk_user_modif integer, - import_key varchar(14), + import_key varchar(14), + model_pdf varchar(255), status integer NOT NULL, fk_product integer NOT NULL, date_start_planned datetime, diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 4cefbc159a0..aa297d0cfe9 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -108,7 +108,7 @@ class MyObject extends CommonObject 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), + 'status' =>array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')), ); /** diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 9c61d4901ce..16323790e97 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -143,7 +143,10 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Action to move up and down lines of object - //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; + + // Action to build doc + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'set_thirdparty' && $permissiontoadd) {