mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
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:
parent
d4a85d9fba
commit
1f742c7464
|
|
@ -1289,12 +1289,12 @@ class AskPriceSupplier extends CommonObject
|
|||
$soc->fetch($this->socid);
|
||||
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$num = $this->ref;
|
||||
}
|
||||
$this->newref = $num;
|
||||
|
|
|
|||
|
|
@ -1481,12 +1481,12 @@ class Propal extends CommonObject
|
|||
$soc->fetch($this->socid);
|
||||
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$num = $this->ref;
|
||||
}
|
||||
$this->newref = $num;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* 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-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* 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)
|
||||
{
|
||||
$result = $object->delete($user);
|
||||
|
|
|
|||
|
|
@ -263,14 +263,14 @@ class Commande extends CommonOrder
|
|||
// Protection
|
||||
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;
|
||||
}
|
||||
|
||||
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))))
|
||||
{
|
||||
$this->error='Permission denied';
|
||||
$this->error='ErrorPermissionDenied';
|
||||
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ class Commande extends CommonOrder
|
|||
$result=$soc->set_as_client();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1827,7 +1827,7 @@ class Facture extends CommonInvoice
|
|||
{
|
||||
$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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ class Contrat extends CommonObject
|
|||
$result=$this->thirdparty->set_as_client();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ class Expedition extends CommonObject
|
|||
$result=$soc->set_as_client();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ class Fichinter extends CommonObject
|
|||
$now=dol_now();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$soc->fetch($this->fourn_id);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
@ -684,7 +684,7 @@ class CommandeFournisseur extends CommonOrder
|
|||
$soc->fetch($this->fourn_id);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -925,7 +925,7 @@ class FactureFournisseur extends CommonInvoice
|
|||
{
|
||||
$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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1672,7 +1672,10 @@ elseif (! empty($object->id))
|
|||
$object->date_commande=dol_now();
|
||||
|
||||
// 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;
|
||||
|
||||
if ($newref < 0)
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ class Livraison extends CommonObject
|
|||
$soc = new Societe($this->db);
|
||||
$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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user