diff --git a/htdocs/includes/modules/societe/mod_codeclient_tigre.php b/htdocs/includes/modules/societe/mod_codeclient_tigre.php index eae36b29954..6ce9d6d68df 100644 --- a/htdocs/includes/modules/societe/mod_codeclient_tigre.php +++ b/htdocs/includes/modules/societe/mod_codeclient_tigre.php @@ -383,9 +383,10 @@ class mod_codeclient_tigre extends ModeleThirdPartyCode * \param $db Handler acces base * \param $code Code a vérifier/corriger * \param $soc Objet societe + * \param $type 0 = client/prospect , 1 = fournisseur * \return int <0 si KO, 0 si OK */ - function verif($db, &$code, $soc) + function verif($db, &$code, $soc, $type) { $result=0; $code = strtoupper(trim($code)); @@ -403,11 +404,11 @@ class mod_codeclient_tigre extends ModeleThirdPartyCode { $result=-3; } - else if ($soc->prefixCustomerIsRequired && !$soc->prefix_comm) + else if ($type == 0 && $soc->prefixCustomerIsRequired && !$soc->prefix_comm) { $result=-4; } - else if ($soc->prefixSupplierIsRequired && !$soc->prefix_comm) + else if ($type == 1 && $soc->prefixSupplierIsRequired && !$soc->prefix_comm) { $result=-5; } diff --git a/htdocs/soc.php b/htdocs/soc.php index d4d99cf933f..aaa3563d255 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -672,7 +672,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print ''.$langs->trans('CustomerCode').''; print '
'; - if (((!$soc->client && !$soc->code_client)|| $soc->code_client == -1) && $modCodeClient->code_auto == 1) + if ((!$soc->code_client || $soc->code_client == -1) && $modCodeClient->code_auto == 1) { print ''; print $langs->trans('AutomaticallyGenerated').' '; @@ -701,7 +701,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print ''.$langs->trans('SupplierCode').''; print '
'; - if (((!$soc->fournisseur && !$soc->code_fournisseur) || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto == 1) + if ((!$soc->code_fournisseur || $soc->code_fournisseur == -1) && $modCodeFournisseur->code_auto == 1) { print ''; print $langs->trans('AutomaticallyGenerated').' '; diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 3c1a1591aba..49906c91bb7 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1549,7 +1549,8 @@ class Societe $mod = new $var; dolibarr_syslog("Societe::check_codeclient code_client=".$this->code_client." module=".$var); - return $mod->verif($this->db, $this->code_client, $this); + $result = $mod->verif($this->db, $this->code_client, $this, 0); + return $result; } else { @@ -1573,7 +1574,8 @@ class Societe $mod = new $var; dolibarr_syslog("Societe::check_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$var); - return $mod->verif($this->db, $this->code_fournisseur, $this); + $result = $mod->verif($this->db, $this->code_fournisseur, $this ,1); + return $result; } else {