diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index e27cd0a2e1c..14a165315f4 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -170,6 +170,13 @@ if (empty($reshook)) { $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency = price2num(GETPOST('efficiency', 'alpha')); $fk_unit = GETPOST('fk_unit', 'alphanohtml'); + + if(!empty($idprod)){ + $product = new Product($db); + $res = $product->fetch($idprod); + if($res > 0 && $product->type == Product::TYPE_SERVICE) $fk_default_workstation = $product->fk_default_workstation; + } + if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; @@ -206,7 +213,7 @@ if (empty($reshook)) { } } - $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit, $array_options); + $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null, $fk_unit, $array_options, $fk_default_workstation); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e10139f3711..397537b8612 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -572,7 +572,7 @@ class BOM extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, Id of created object if OK */ - public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit = '', $array_options = 0) + public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null, $fk_unit = '', $array_options = 0, $fk_default_workstation = null) { global $mysoc, $conf, $langs, $user; @@ -641,6 +641,7 @@ class BOM extends CommonObject $this->line->import_key = $import_key; $this->line->position = $rankToUse; $this->line->fk_unit = $fk_unit; + $this->line->fk_default_workstation = $fk_default_workstation; if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; @@ -1670,6 +1671,7 @@ class BOMLine extends CommonObjectLine 'fk_unit' => array('type'=>'integer', 'label'=>'Unit', 'enabled'=>1, 'visible'=>1, 'position'=>120, 'notnull'=>-1,), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'fk_default_workstation' =>array('type'=>'integer', 'label'=>'DefaultWorkstation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>25) ); /** diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f7587daf331..20eb3a94704 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -741,6 +741,7 @@ class Mo extends CommonObject $moline->position = $line->position; $moline->qty_frozen = $line->qty_frozen; $moline->disable_stock_change = $line->disable_stock_change; + if(!empty($line->fk_default_workstation)) $moline->fk_default_workstation = $line->fk_default_workstation; $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { @@ -1720,6 +1721,7 @@ class MoLine extends CommonObjectLine 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>170), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModification', 'enabled'=>1, 'visible'=>-1, 'position'=>175), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'position'=>180), + 'fk_default_workstation' =>array('type'=>'integer', 'label'=>'DefaultWorkstation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), ); public $rowid;