Merge pull request #25228 from atm-greg/Fix_missing_call_trigger_variable

add call_trigger variable
This commit is contained in:
Laurent Destailleur 2023-07-01 12:27:24 +02:00 committed by GitHub
commit 683af7937c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View file

@ -432,10 +432,11 @@ class Contact extends CommonObject
/**
* Add a contact into database
*
* @param User $user Object user that create
* @return int <0 if KO, >0 if OK
* @param User $user Object user that create
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
public function create($user)
public function create($user, $notrigger = 0)
{
global $conf, $langs;
@ -513,7 +514,7 @@ class Contact extends CommonObject
}
}
if (!$error) {
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('CONTACT_CREATE', $user);
if ($result < 0) {

View file

@ -872,10 +872,11 @@ class Societe extends CommonObject
* Create third party in database.
* $this->code_client = -1 and $this->code_fournisseur = -1 means automatic assignement.
*
* @param User $user Object of user that ask creation
* @return int >=0 if OK, <0 if KO
* @param User $user Object of user that ask creation
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >=0 if OK, <0 if KO
*/
public function create(User $user)
public function create(User $user, $notrigger = 0)
{
global $langs, $conf, $mysoc;
@ -1009,7 +1010,7 @@ class Societe extends CommonObject
$this->add_commercial($user, $user->id);
}
if ($ret >= 0) {
if ($ret >= 0 && !$notrigger) {
// Call trigger
$result = $this->call_trigger('COMPANY_CREATE', $user);
if ($result < 0) {
@ -1052,12 +1053,13 @@ class Societe extends CommonObject
/**
* Create a contact/address from thirdparty
*
* @param User $user Object user
* @param int $no_email 1=Do not send mailing, 0=Ok to recieve mailling
* @param array $tags Array of tag to affect to contact
* @return int <0 if KO, >0 if OK
* @param User $user Object user
* @param int $no_email 1=Do not send mailing, 0=Ok to recieve mailling
* @param array $tags Array of tag to affect to contact
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
public function create_individual(User $user, $no_email = 0, $tags = array())
public function create_individual(User $user, $no_email = 0, $tags = array(), $notrigger = 0)
{
global $conf;
@ -1085,7 +1087,7 @@ class Societe extends CommonObject
$this->setUpperOrLowerCase();
$contact->phone_pro = $this->phone;
$contactId = $contact->create($user);
$contactId = $contact->create($user, $notrigger);
if ($contactId < 0) {
$error++;
$this->error = $contact->error;