This commit is contained in:
Laurent Destailleur 2015-09-12 12:50:55 +02:00
parent db1d9d6d8e
commit 1966d75ced
2 changed files with 17 additions and 12 deletions

View File

@ -266,7 +266,7 @@ class FactureFournisseur extends CommonInvoice
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
$result=$this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found
if ($result < 0)
{
$error++;
@ -274,11 +274,15 @@ class FactureFournisseur extends CommonInvoice
}
}
else if ($reshook < 0) $error++;
// Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_CREATE',$user);
if ($result < 0) $error++;
// End call triggers
if (! $error)
{
// Call trigger
$result=$this->call_trigger('BILL_SUPPLIER_CREATE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
@ -307,7 +311,7 @@ class FactureFournisseur extends CommonInvoice
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->db->rollback();
return -2;
}

View File

@ -364,7 +364,7 @@ if (empty($reshook))
if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
// If creation from another object of another module
if ($_POST['origin'] && $_POST['originid'])
if (! $error && $_POST['origin'] && $_POST['originid'])
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin'];
@ -468,17 +468,17 @@ if (empty($reshook))
$error++;
}
}
// If some invoice's lines already known
else
else if (! $error)
{
$id = $object->create($user);
if ($id < 0)
{
$error++;
}
if (! $error)
{
// If some invoice's lines already known
for ($i = 1 ; $i < 9 ; $i++)
{
$label = $_POST['label'.$i];
@ -513,7 +513,8 @@ if (empty($reshook))
{
$langs->load("errors");
$db->rollback();
setEventMessage($langs->trans($object->error), 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
}