diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 26162295f84..b148694955b 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -512,9 +512,15 @@ class Commande extends CommonObject // Clean parameters $this->brouillon = 1; // On positionne en mode brouillon la commande - dol_syslog("Commande::create"); + dol_syslog("Commande::create user=".$user->id); // Check parameters + if (empty($this->ref)) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); + dol_syslog("Commande::create ".$this->error, LOG_ERR); + return -1; + } if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0) { $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source")); diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 0a1bb27c10e..a6210996dea 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -147,6 +147,14 @@ class Facture extends CommonObject dol_syslog("Facture::Create user=".$user->id); + // Check parameters + if (empty($this->ref)) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); + dol_syslog("Facture::create ".$this->error, LOG_ERR); + return -1; + } + $soc = new Societe($this->db); $soc->fetch($this->socid); diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index 3026cdc42aa..22b25557a43 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -518,13 +518,22 @@ class Propal extends CommonObject { global $langs,$conf,$mysoc; - // on verifie si la ref n'est pas utilisee - $soc = new Societe($this->db); - $soc->fetch($this->socid); - $this->verifyNumRef($soc); - // Clean parameters $this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600); + + dol_syslog("Propal::Create"); + + // Check parameters + if (empty($this->ref)) + { + $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref")); + dol_syslog("Facture::create ".$this->error, LOG_ERR); + return -1; + } + $soc = new Societe($this->db); + $soc->fetch($this->socid); + $this->verifyNumRef($soc); // Check ref is not yet used + $this->db->begin(); diff --git a/htdocs/user.class.php b/htdocs/user.class.php index 8232abba0ce..eb55390c942 100644 --- a/htdocs/user.class.php +++ b/htdocs/user.class.php @@ -469,9 +469,9 @@ class User extends CommonObject /** - \brief Charge dans l'objet user, la liste des permissions auxquelles l'utilisateur a droit - \param moduletag nom du module dont il faut recuperer les droits ('' par defaut signifie tous les droits) - */ + * \brief Charge dans l'objet user, la liste des permissions auxquelles l'utilisateur a droit + * \param moduletag nom du module dont il faut recuperer les droits ('' par defaut signifie tous les droits) + */ function getrights($moduletag='') { global $conf; diff --git a/mysql/migration/repair.sql b/mysql/migration/repair.sql index e8ed4eba1f6..9817d693940 100644 --- a/mysql/migration/repair.sql +++ b/mysql/migration/repair.sql @@ -11,3 +11,6 @@ delete from llx_facture where facnumber = '(PROV)'; delete from llx_commande where ref = '(PROV)'; delete from llx_propal where ref = '(PROV)'; +delete from llx_facture where facnumber = ''; +delete from llx_commande where ref = ''; +delete from llx_propal where ref = '';