2
0
forked from Wavyzz/dolibarr

FIX update extrafields

This commit is contained in:
Laurent Destailleur
2018-08-12 16:29:26 +02:00
parent e1877625a0
commit 12e21b4886
14 changed files with 90 additions and 70 deletions

View File

@@ -464,7 +464,7 @@ class Adherent extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -172,7 +172,7 @@ class AdherentType extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -1464,6 +1464,8 @@ class Propal extends CommonObject
*/
function update(User $user, $notrigger=0)
{
global $conf;
$error=0;
// Clean parameters
@@ -1512,16 +1514,22 @@ class Propal extends CommonObject
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (! $notrigger)
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
}
// Commit or rollback
if ($error)

View File

@@ -3067,16 +3067,22 @@ class Commande extends CommonOrder
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (! $notrigger)
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
}
// Commit or rollback
if ($error)

View File

@@ -1549,6 +1549,8 @@ class Facture extends CommonInvoice
*/
function update(User $user, $notrigger=0)
{
global $conf;
$error=0;
// Clean parameters
@@ -1614,16 +1616,22 @@ class Facture extends CommonInvoice
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (! $notrigger)
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
}
// Commit or rollback
if ($error)

View File

@@ -371,9 +371,7 @@ class Contact extends CommonObject
$action='update';
// Actions on extra fields
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -381,7 +379,6 @@ class Contact extends CommonObject
$error++;
}
}
}
if (! $error && $this->user_id > 0)
{

View File

@@ -925,9 +925,7 @@ class Contrat extends CommonObject
}
}
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -935,7 +933,6 @@ class Contrat extends CommonObject
$error++;
}
}
}
// Insert contacts commerciaux ('SALESREPSIGN','contrat')
if (! $error)
@@ -1283,18 +1280,7 @@ class Contrat extends CommonObject
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Call triggers
$result=$this->call_trigger('CONTRACT_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -1303,6 +1289,14 @@ class Contrat extends CommonObject
}
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('CONTRACT_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
// Commit or rollback
if ($error)
{

View File

@@ -7044,9 +7044,7 @@ abstract class CommonObject
}
// Update extrafield
if (! $error)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -7054,7 +7052,6 @@ abstract class CommonObject
$error++;
}
}
}
// Triggers
if (! $error && ! $notrigger)

View File

@@ -313,7 +313,7 @@ class Expedition extends CommonObject
}
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -541,8 +541,7 @@ class Expedition extends CommonObject
*/
$result=$this->fetch_thirdparty();
// Retreive all extrafield
// fetch optionals attributes and labels
// Retreive extrafields
$this->fetch_optionals();
/*
@@ -2412,7 +2411,8 @@ class ExpeditionLigne extends CommonObjectLine
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -222,7 +222,7 @@ class Fichinter extends CommonObject
if (! $resql) $error++;
}
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -285,6 +285,8 @@ class Fichinter extends CommonObject
$this->fk_project = 0;
}
$error = 0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
@@ -299,8 +301,16 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
if ($this->db->query($sql))
{
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $notrigger)
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_MODIFY',$user);
@@ -372,8 +382,7 @@ class Fichinter extends CommonObject
if ($this->statut == 0) $this->brouillon = 1;
// Retreive all extrafield
// fetch optionals attributes and labels
// Retreive extrafields
$this->fetch_optionals();
/*

View File

@@ -916,7 +916,7 @@ class Product extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -754,6 +754,7 @@ class Societe extends CommonObject
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1)
{
global $langs,$conf,$hookmanager;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (empty($id)) $id = $this->id;
@@ -1053,7 +1054,7 @@ class Societe extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -1013,7 +1013,7 @@ class SupplierProposal extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -1022,7 +1022,7 @@ class SupplierProposal extends CommonObject
}
}
if (! $erro && ! $notrigger)
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user);

View File

@@ -1581,7 +1581,7 @@ class User extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)