Merge pull request #20522 from ATM-Consulting/FIX_16.0_missing_triggers_facturerec_facturefournisseurrec

FIX: missing trigger DELETE for FactureRec, FactureFournisseurRec
This commit is contained in:
Laurent Destailleur 2022-04-01 20:13:37 +02:00 committed by GitHub
commit 2eaae819f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
*/ */
class FactureRec extends CommonInvoice class FactureRec extends CommonInvoice
{ {
const TRIGGER_PREFIX = 'BILLREC';
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
@ -501,7 +502,7 @@ class FactureRec extends CommonInvoice
if (!$error && !$notrigger) { if (!$error && !$notrigger) {
// Call trigger // Call trigger
$result = $this->call_trigger('BILLREC_UPDATE', $user); $result = $this->call_trigger('BILLREC_MODIFY', $user);
if ($result < 0) { if ($result < 0) {
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
@ -816,7 +817,14 @@ class FactureRec extends CommonInvoice
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$error = -2; $error = -2;
} }
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('BILLREC_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (!$error) { if (!$error) {
$this->db->commit(); $this->db->commit();
return 1; return 1;

View File

@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
*/ */
class FactureFournisseurRec extends CommonInvoice class FactureFournisseurRec extends CommonInvoice
{ {
const TRIGGER_PREFIX = 'SUPPLIERBILLREC';
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
@ -524,7 +525,7 @@ class FactureFournisseurRec extends CommonInvoice
if (!$error && !$notrigger) { if (!$error && !$notrigger) {
// Call trigger // Call trigger
$result = $this->call_trigger('BILLREC_UPDATE', $user); $result = $this->call_trigger('SUPPLIERBILLREC_MODIFY', $user);
if ($result < 0) { if ($result < 0) {
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
@ -820,8 +821,15 @@ class FactureFournisseurRec extends CommonInvoice
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$error = -2; $error = -2;
} }
if (!$error && !$notrigger) {
if (!$error) { // Call trigger
$result = $this->call_trigger('SUPPLIERBILLREC_DELETE', $user);
if ($result < 0) {
$error++;
}
// End call triggers
}
if (! $error) {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {