diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 16fdc406db9..5a4f02c5f06 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1291,6 +1291,25 @@ if (empty($reshook)) if ($id > 0 && ! $error) { $db->commit(); + + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($object->lines)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); exit(); }