diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 00734ccb680..0269babd064 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2518,6 +2518,20 @@ class Facture extends CommonInvoice { $keymin = strtolower($key); $i = (int) preg_replace('/[^0-9]/', '', $key); + if ($i == 1) { + if (!is_object($this->thirdparty)) { + $langs->load('errors'); + $this->error = $langs->trans('ErrorInvoiceLoadThirdParty', $this->ref); + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + if (!property_exists($this->thirdparty, $keymin)) { + $langs->load('errors'); + $this->error = $langs->trans('ErrorInvoiceLoadThirdPartyKey', $keymin, $this->ref); + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } $vallabel = $this->thirdparty->$keymin; if ($i > 0) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 087fcba9e56..94a1cf16a38 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -257,6 +257,8 @@ ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page ErrorAParameterIsRequiredForThisOperation=A parameter is mandatory for this operation ErrorYouMustFirstSetupYourChartOfAccount=You must first setup your chart of account +ErrorInvoiceLoadThirdParty=Can't load third-party object for invoice "%s" +ErrorInvoiceLoadThirdPartyKey=Third-party key "%s" no set for invoice "%s" # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. @@ -289,4 +291,4 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E WarningTheHiddenOptionIsOn=Warning, the hidden option %s is on. WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. -WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. \ No newline at end of file +WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here.