Fix #16524 : Add support disassemble BOM
This commit is contained in:
parent
dfb791837c
commit
c00d64855a
@ -92,8 +92,8 @@ class BOM extends CommonObject
|
||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',),
|
||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'autofocusoncreate'=>1),
|
||||
//'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassembly')),
|
||||
'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')),
|
||||
'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble')),
|
||||
//'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')),
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500'),
|
||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
|
||||
'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'),
|
||||
|
||||
@ -632,9 +632,21 @@ class Mo extends CommonObject
|
||||
$moline->fk_mo = $this->id;
|
||||
$moline->qty = $this->qty;
|
||||
$moline->fk_product = $this->fk_product;
|
||||
$moline->role = 'toproduce';
|
||||
$moline->position = 1;
|
||||
|
||||
if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume.
|
||||
include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
$bom = new Bom($this->db);
|
||||
$bom->fetch($this->fk_bom);
|
||||
if ($bom->bomtype == 1) {
|
||||
$role = 'toproduce';
|
||||
$moline->role = 'toconsume';
|
||||
}else {
|
||||
$role = 'toconsume';
|
||||
$moline->role = 'toproduce';
|
||||
}
|
||||
}
|
||||
|
||||
$resultline = $moline->create($user, false); // Never use triggers here
|
||||
if ($resultline <= 0) {
|
||||
$error++;
|
||||
@ -644,9 +656,6 @@ class Mo extends CommonObject
|
||||
}
|
||||
|
||||
if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume.
|
||||
include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
$bom = new Bom($this->db);
|
||||
$bom->fetch($this->fk_bom);
|
||||
if ($bom->id > 0) {
|
||||
// Lines to consume
|
||||
if (!$error) {
|
||||
@ -667,7 +676,7 @@ class Mo extends CommonObject
|
||||
break;
|
||||
} else {
|
||||
$moline->fk_product = $line->fk_product;
|
||||
$moline->role = 'toconsume';
|
||||
$moline->role = $role;
|
||||
$moline->position = $line->position;
|
||||
$moline->qty_frozen = $line->qty_frozen;
|
||||
$moline->disable_stock_change = $line->disable_stock_change;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user