FIX Add a test to save life when ref of object (invoice ref, order ref,

...) was empty. The was no way to go back to a clean situation, even
after vaidating again the object.
This commit is contained in:
Laurent Destailleur 2015-10-06 16:38:27 +02:00
parent d4a85d9fba
commit 1f742c7464
12 changed files with 21 additions and 18 deletions

View File

@ -1289,7 +1289,7 @@ class AskPriceSupplier extends CommonObject
$soc->fetch($this->socid); $soc->fetch($this->socid);
// Define new ref // Define new ref
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }

View File

@ -1481,7 +1481,7 @@ class Propal extends CommonObject
$soc->fetch($this->socid); $soc->fetch($this->socid);
// Define new ref // Define new ref
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@ -165,7 +165,7 @@ if (empty($reshook))
} }
} }
// Suppression de la commande // Remove order
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer)
{ {
$result = $object->delete($user); $result = $object->delete($user);

View File

@ -263,14 +263,14 @@ class Commande extends CommonOrder
// Protection // Protection
if ($this->statut == self::STATUS_VALIDATED) if ($this->statut == self::STATUS_VALIDATED)
{ {
dol_syslog(get_class($this)."::valid no draft status", LOG_WARNING); dol_syslog(get_class($this)."::valid action abandonned: no draft status", LOG_WARNING);
return 0; return 0;
} }
if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
{ {
$this->error='Permission denied'; $this->error='ErrorPermissionDenied';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -287,7 +287,7 @@ class Commande extends CommonOrder
$result=$soc->set_as_client(); $result=$soc->set_as_client();
// Define new ref // Define new ref
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }

View File

@ -1827,7 +1827,7 @@ class Facture extends CommonInvoice
{ {
$num = $force_number; $num = $force_number;
} }
else if (preg_match('/^[\(]?PROV/i', $this->ref)) else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
{ {
if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date
{ {

View File

@ -402,7 +402,7 @@ class Contrat extends CommonObject
$result=$this->thirdparty->set_as_client(); $result=$this->thirdparty->set_as_client();
// Define new ref // Define new ref
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($this->thirdparty); $num = $this->getNextNumRef($this->thirdparty);
} }

View File

@ -589,7 +589,7 @@ class Expedition extends CommonObject
$result=$soc->set_as_client(); $result=$soc->set_as_client();
// Define new ref // Define new ref
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{ {
$numref = $this->getNextNumRef($soc); $numref = $this->getNextNumRef($soc);
} }

View File

@ -400,7 +400,7 @@ class Fichinter extends CommonObject
$now=dol_now(); $now=dol_now();
// Define new ref // Define new ref
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref))) if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($this->thirdparty); $num = $this->getNextNumRef($this->thirdparty);
} }

View File

@ -388,7 +388,7 @@ class CommandeFournisseur extends CommonOrder
$soc->fetch($this->fourn_id); $soc->fetch($this->fourn_id);
// Check if object has a temporary ref // Check if object has a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }
@ -684,7 +684,7 @@ class CommandeFournisseur extends CommonOrder
$soc->fetch($this->fourn_id); $soc->fetch($this->fourn_id);
// Check if object has a temporary ref // Check if object has a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($soc); $num = $this->getNextNumRef($soc);
} }

View File

@ -925,7 +925,7 @@ class FactureFournisseur extends CommonInvoice
{ {
$num = $force_number; $num = $force_number;
} }
else if (preg_match('/^[\(]?PROV/i', $this->ref)) else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
{ {
$num = $this->getNextNumRef($this->client); $num = $this->getNextNumRef($this->client);
} }

View File

@ -1672,7 +1672,10 @@ elseif (! empty($object->id))
$object->date_commande=dol_now(); $object->date_commande=dol_now();
// We check if number is temporary number // We check if number is temporary number
if (preg_match('/^[\(]?PROV/i',$object->ref)) $newref = $object->getNextNumRef($object->thirdparty); if (preg_match('/^[\(]?PROV/i',$object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life
{
$newref = $object->getNextNumRef($object->thirdparty);
}
else $newref = $object->ref; else $newref = $object->ref;
if ($newref < 0) if ($newref < 0)

View File

@ -379,7 +379,7 @@ class Livraison extends CommonObject
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->socid); $soc->fetch($this->socid);
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life
{ {
$numref = $objMod->livraison_get_num($soc,$this); $numref = $objMod->livraison_get_num($soc,$this);
} }