Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
f3cd8f7d27
2 changed files with 52 additions and 1 deletions
|
|
@ -15,6 +15,10 @@ ListOfBOMs=Bills of material - BOM
|
|||
ListOfManufacturingOrders=Manufacturing Orders
|
||||
NewBOM=New bill of materials
|
||||
ProductBOMHelp=Product to create (or disassemble) with this BOM.<br>Note: Products with the property 'Nature of product' = 'Raw material' are not visible into this list.
|
||||
CloneDefBomProduct=Clone the default BOM to use to manufacture the product
|
||||
CloneOtherBomsProduct=Clone all BOMs that can be used to manufacture the product
|
||||
BOMofRef=BOM of %s
|
||||
ErrorProductCloneBom=Error: Failed to clone a BOM
|
||||
BOMsNumberingModules=BOM numbering templates
|
||||
BOMsModelModule=BOM document templates
|
||||
MOsNumberingModules=MO numbering templates
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ if (isModEnabled('accounting')) {
|
|||
}
|
||||
if (isModEnabled('bom')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||
$langs->load("mrp");
|
||||
}
|
||||
if (isModEnabled('workstation')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
|
||||
|
|
@ -964,6 +965,43 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$error && isModEnabled('bom') && $user->hasRight('bom', 'write')) {
|
||||
$defbomidac = 0; // to avoid cloning same BOM twice
|
||||
if (GETPOST('clone_defbom') && $object->fk_default_bom > 0) {
|
||||
$bomstatic = new BOM($db);
|
||||
$bomclone = $bomstatic->createFromClone($user, $object->fk_default_bom);
|
||||
if ((int) $bomclone < 0) {
|
||||
setEventMessages($langs->trans('ErrorProductClone').' : '.$langs->trans('ErrorProductCloneBom'), null, 'warnings');
|
||||
} else {
|
||||
$defbomidac = $object->fk_default_bom;
|
||||
$clone->fk_default_bom = $bomclone->id;
|
||||
$clone->update($id, $user);
|
||||
$bomclone->fk_product = $id;
|
||||
$bomclone->label = $langs->trans('BOMofRef', $clone->ref);
|
||||
$bomclone->update($user);
|
||||
$bomclone->validate($user);
|
||||
}
|
||||
}
|
||||
if (GETPOST('clone_otherboms')) {
|
||||
$bomstatic = new BOM($db);
|
||||
$bomlist = $bomstatic->fetchAll("", "", 0, 0, 'fk_product:=:'.(int) $object->id);
|
||||
if (is_array($bomlist)) {
|
||||
foreach ($bomlist as $bom2clone) {
|
||||
if ($bom2clone->id != $defbomidac) { // to avoid cloning same BOM twice
|
||||
$bomclone = $bomstatic->createFromClone($user, $bom2clone->id);
|
||||
if ((int) $bomclone < 0) {
|
||||
setEventMessages($langs->trans('ErrorProductClone').' : '.$langs->trans('ErrorProductCloneBom'), null, 'warnings');
|
||||
} else {
|
||||
$bomclone->fk_product = $id;
|
||||
$bomclone->label = $langs->trans('BOMofRef', $clone->ref);
|
||||
$bomclone->update($user);
|
||||
$bomclone->validate($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// $clone->clone_fournisseurs($object->id, $id);
|
||||
} else {
|
||||
if ($clone->error == 'ErrorProductAlreadyExists') {
|
||||
|
|
@ -2889,7 +2927,16 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->d
|
|||
if (getDolGlobalString('PRODUIT_SOUSPRODUITS')) {
|
||||
$formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1);
|
||||
}
|
||||
|
||||
if (isModEnabled('bom') && $user->hasRight('bom', 'write')) {
|
||||
if ($object->fk_default_bom > 0) {
|
||||
$formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_defbom', 'label' => $langs->trans("CloneDefBomProduct"), 'value' => getDolGlobalInt('BOM_CLONE_DEFBOM'));
|
||||
}
|
||||
$bomstatic = new BOM($db);
|
||||
$bomlist = $bomstatic->fetchAll("", "", 0, 0, 'fk_product:=:'.(int) $object->id);
|
||||
if (is_array($bomlist) && count($bomlist) > 0) {
|
||||
$formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_otherboms', 'label' => $langs->trans("CloneOtherBomsProduct"), 'value' => 0);
|
||||
}
|
||||
}
|
||||
$formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneProduct', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 350, 600);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue