diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 1d9dd28f9d7..5584ccc40f6 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -63,6 +63,7 @@ INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUE ALTER TABLE llx_product ADD COLUMN fk_default_bom integer DEFAULT NULL; +ALTER TABLE llx_mrp_mo ADD COLUMN mrptype integer DEFAULT 0; DELETE FROM llx_menu WHERE type = 'top' AND module = 'cashdesk' AND mainmenu = 'cashdesk'; diff --git a/htdocs/install/mysql/tables/llx_mrp_mo.sql b/htdocs/install/mysql/tables/llx_mrp_mo.sql index de1933ccfed..185ea1583c9 100644 --- a/htdocs/install/mysql/tables/llx_mrp_mo.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.sql @@ -17,8 +17,9 @@ CREATE TABLE llx_mrp_mo( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) DEFAULT '(PROV)' NOT NULL, entity integer DEFAULT 1 NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + mrptype integer DEFAULT 0, -- 0 for a manufacture MO, 1 for a dismantle MO label varchar(255), qty real NOT NULL, fk_warehouse integer, diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 2414a92cefb..a1ccf238f0a 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -55,6 +55,7 @@ WarehouseForProduction=Warehouse for production CreateMO=Create MO ToConsume=To consume ToProduce=To produce +ToObtain=To obtain QtyAlreadyConsumed=Qty already consumed QtyAlreadyProduced=Qty already produced QtyRequiredIfNoLoss=Qty required if there is no loss (Manufacturing efficiency is 100%%) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 535cd23cfa5..fcf54eb364e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -101,6 +101,7 @@ class Mo extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1), 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300', 'csslist'=>'nowraponall'), + 'mrptype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>34, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth150', 'csslist'=>'minwidth150 center'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'2', 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200'), @@ -121,8 +122,9 @@ class Mo extends CommonObject 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>2, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '9'=>'Canceled')), ); public $rowid; - public $ref; public $entity; + public $ref; + public $mrptype; public $label; public $qty; public $fk_warehouse; @@ -253,7 +255,7 @@ class Mo extends CommonObject $this->db->begin(); // Check that product is not a kit/virtual product - if (empty($conf->global->ALLOW_USE_KITS_INTO_BOM_AND_MO) and $this->fk_product > 0) { + if (empty($conf->global->ALLOW_USE_KITS_INTO_BOM_AND_MO) && $this->fk_product > 0) { include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $tmpproduct = new Product($this->db); $tmpproduct->fetch($this->fk_product); @@ -265,6 +267,14 @@ class Mo extends CommonObject } } + if ($this->fk_bom > 0) { + // If there is a nown BOM, we force the type of MO to the type of BOM + $tmpbom = new BOM($this->db); + $tmpbom->fetch($this->fk_bom); + + $this->mrptype = $tmpbom->bomtype; + } + if (!$error) { $idcreated = $this->createCommon($user, $notrigger); if ($idcreated <= 0) { @@ -273,7 +283,7 @@ class Mo extends CommonObject } if (!$error) { - $result = $this->updateProduction($user, $notrigger); + $result = $this->updateProduction($user, $notrigger); // Insert lines from BOM if ($result <= 0) { $error++; } @@ -638,7 +648,7 @@ class Mo extends CommonObject $moline->fk_product = $this->fk_product; $moline->position = 1; - if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume. + if ($this->fk_bom > 0) { // If a BOM is defined, we know what to produce. include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; $bom = new Bom($this->db); $bom->fetch($this->fk_bom); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 6eaf42ed833..fc8cab806c7 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -49,6 +49,7 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // Initialize technical objects $object = new Mo($db); $objectbom = new BOM($db); + $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('mocard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -74,13 +75,14 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -if (GETPOST('fk_bom', 'int')) { +if (GETPOST('fk_bom', 'int') > 0) { $objectbom->fetch(GETPOST('fk_bom', 'int')); if ($action != 'add') { // We force calling parameters if we are not in the submit of creation of MO $_POST['fk_product'] = $objectbom->fk_product; $_POST['qty'] = $objectbom->qty; + $_POST['mrptype'] = $objectbom->bomtype; $_POST['fk_warehouse'] = $objectbom->fk_warehouse; $_POST['note_private'] = $objectbom->note_private; } @@ -205,6 +207,13 @@ llxHeader('', $title, ''); // Part to create if ($action == 'create') { + if (GETPOST('fk_bom', 'int') > 0) { + $titlelist = $langs->trans("ToConsume"); + if ($objectbom->bomtype == 1) { + $titlelist = $langs->trans("ToObtain"); + } + } + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Mo")), '', 'mrp'); print '