This commit is contained in:
Laurent Destailleur 2020-11-01 17:01:26 +01:00
parent ad922bfde6
commit 72160deef7
14 changed files with 30 additions and 7 deletions

View File

@ -717,6 +717,7 @@ if (empty($reshook))
$outputlangs->load('products'); $outputlangs->load('products');
} }
$model = $object->modelpdf; $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);

View File

@ -2523,7 +2523,7 @@ class Facture extends CommonInvoice
$this->db->begin(); $this->db->begin();
// Check parameters // Check parameters
if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement if ($this->type == self::TYPE_REPLACEMENT) // if this is a replacement invoice
{ {
// Controle que facture source connue // Controle que facture source connue
if ($this->fk_facture_source <= 0) if ($this->fk_facture_source <= 0)
@ -2533,7 +2533,7 @@ class Facture extends CommonInvoice
return -10; return -10;
} }
// Charge la facture source a remplacer // Load source invoice that has been replaced
$facreplaced = new Facture($this->db); $facreplaced = new Facture($this->db);
$result = $facreplaced->fetch($this->fk_facture_source); $result = $facreplaced->fetch($this->fk_facture_source);
if ($result <= 0) if ($result <= 0)
@ -2543,7 +2543,7 @@ class Facture extends CommonInvoice
return -11; return -11;
} }
// Controle que facture source non deja remplacee par une autre // Check that source invoice not already replaced by another one.
$idreplacement = $facreplaced->getIdReplacingInvoice('validated'); $idreplacement = $facreplaced->getIdReplacingInvoice('validated');
if ($idreplacement && $idreplacement != $this->id) if ($idreplacement && $idreplacement != $this->id)
{ {
@ -4397,15 +4397,14 @@ class Facture extends CommonInvoice
* @param int $hidedetails Hide details of lines * @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description * @param int $hidedesc Hide description
* @param int $hideref Hide ref * @param int $hideref Hide ref
* @param null|array $moreparams Array to provide more information * @param null|array $moreparams Array to provide more information
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{ {
global $conf, $langs; global $conf, $langs;
$langs->load("bills"); $outputlangs->loadLangs(array("bills", "products"));
$outputlangs->load("products");
if (!dol_strlen($modele)) if (!dol_strlen($modele))
{ {

View File

@ -320,6 +320,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd)
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
$model = $object->modelpdf; $model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records $ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);

View File

@ -237,6 +237,8 @@ class doc_generic_bom_odt extends ModelePDFBom
} }
} }
$object->fetch_thirdparty();
$dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1];
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -249,6 +249,8 @@ class doc_generic_order_odt extends ModelePDFCommandes
} }
} }
$object->fetch_thirdparty();
$dir = $conf->commande->multidir_output[$object->entity]; $dir = $conf->commande->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -235,6 +235,8 @@ class doc_generic_contract_odt extends ModelePDFContract
} }
} }
$object->fetch_thirdparty();
$dir = $conf->contrat->dir_output; $dir = $conf->contrat->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -249,6 +249,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
} }
} }
$object->fetch_thirdparty();
$dir = $conf->expedition->dir_output."/sending"; $dir = $conf->expedition->dir_output."/sending";
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -248,6 +248,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
} }
} }
$object->fetch_thirdparty();
$dir = $conf->facture->dir_output; $dir = $conf->facture->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -244,6 +244,8 @@ class doc_generic_mo_odt extends ModelePDFMo
} }
} }
$object->fetch_thirdparty();
$dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1];
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -513,6 +513,8 @@ class doc_generic_project_odt extends ModelePDFProjects
} }
} }
$object->fetch_thirdparty();
$dir = $conf->projet->dir_output; $dir = $conf->projet->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -227,7 +227,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
/** /**
* Function to build a document on disk using the generic odt module. * Function to build a document on disk using the generic odt module.
* *
* @param Propale $object Object source to build document * @param Propal $object Object source to build document
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
@ -277,6 +277,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales
} }
} }
$object->fetch_thirdparty();
$dir = $conf->propal->multidir_output[$object->entity]; $dir = $conf->propal->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -241,6 +241,8 @@ class doc_generic_reception_odt extends ModelePdfReception
} }
} }
$object->fetch_thirdparty();
$dir = $conf->reception->dir_output."/reception"; $dir = $conf->reception->dir_output."/reception";
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -275,6 +275,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
} }
} }
$object->fetch_thirdparty();
$dir = $conf->supplier_proposal->dir_output; $dir = $conf->supplier_proposal->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;

View File

@ -257,6 +257,8 @@ class doc_generic_user_odt extends ModelePDFUser
} }
} }
$object->fetch_thirdparty();
$dir = $conf->user->dir_output; $dir = $conf->user->dir_output;
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;