diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c75a0355f82..33eeda9f4b2 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -517,7 +517,9 @@ if ($massaction == 'confirm_createbills') $objecttmp = new Facture($db); if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. else { - + // Load extrafields of order + $cmd->fetch_optionals(); + $objecttmp->socid = $cmd->socid; $objecttmp->type = Facture::TYPE_STANDARD; $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; @@ -534,6 +536,8 @@ if ($massaction == 'confirm_createbills') $objecttmp->origin = 'commande'; $objecttmp->origin_id = $id_order; + $objecttmp->array_options = $cmd->array_options; // Copy extrafields + $res = $objecttmp->create($user); if($res > 0) $nb_bills_created++; @@ -683,6 +687,7 @@ if ($massaction == 'confirm_createbills') if (! $error && $validate_invoices) { $massaction = $action = 'builddoc'; + foreach($TAllFact as &$objecttmp) { $result = $objecttmp->validate($user); @@ -700,7 +705,12 @@ if ($massaction == 'confirm_createbills') $donotredirect = 1; $upload_dir = $conf->facture->dir_output; $permissioncreate=$user->rights->facture->creer; + + // Call action to build doc + $savobject = $object; + $object = $objecttmp; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + $object = $savobject; } $massaction = $action = 'confirm_createbills';