diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index c2dae06ad21..524c58e656c 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1595,6 +1595,9 @@ else
$author->fetch();
}
+ $facidnext=$fac->getIdReplacingInvoice();
+
+
$head = facture_prepare_head($fac);
dolibarr_fiche_head($head, 'compta', $langs->trans('InvoiceCustomer'));
@@ -1673,8 +1676,24 @@ else
*/
if ($_GET['action'] == 'canceled')
{
- $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$fac->ref),'confirm_canceled');
- print '
';
+ // Si il y a une facture de remplacement pas encore validée (etat brouillon),
+ // on ne permet pas de classer abandonner la facture
+ if ($facidnext)
+ {
+ $facturereplacement=new Facture($db);
+ $facturereplacement->fetch($facidnext);
+ $statusreplacement=$facturereplacement->statut;
+ }
+ print "x".$statusreplacement;
+ if ($facidnext && $statusreplacement == 0)
+ {
+ print '
'.$langs->trans("ErrorCantCancelIfReplacementInvoiceNotValidated").'
';
+ }
+ else
+ {
+ $html->form_confirm($_SERVER['PHP_SELF'].'?facid='.$fac->id,$langs->trans('CancelBill'),$langs->trans('ConfirmCancelBill',$fac->ref),'confirm_canceled');
+ print '
';
+ }
}
/*
@@ -1761,7 +1780,6 @@ else
}
print ')';
}
- $facidnext=$fac->getIdReplacingInvoice();
if ($facidnext > 0)
{
$facthatreplace=new Facture($db);
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index e5f6e310a1e..c3147eaf43f 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -1013,7 +1013,7 @@ class Facture extends CommonObject
// Controle que facture source non deja remplacee par une autre
$idreplacement=$facreplaced->getIdReplacingInvoice();
- if ($idreplacement != $rowid)
+ if ($idreplacement && $idreplacement != $rowid)
{
$facreplacement=new Facture($this->db);
$facreplacement->fetch($idreplacement);
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 9d725bfacbb..654f9c836c7 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -90,10 +90,11 @@ ErrorVATIntraNotConfigured=Intracommunautary VAT number not yet defined
ErrorNoPaiementModeConfigured=No paiment mode yet defined
ErrorCreateBankAccount=Creat a bank account then go to Setup panel of Invoice module to define paiement modes
ErrorBillNotFound=Invoice %s does not exists
-ErrorInvoiceAlreadyReplaced=Error, invoice %s has already been replaced by invoice %s
+ErrorInvoiceAlreadyReplaced=Error, you try to validate an invoice to replace invoice %s. But this one has already been replaced by invoice %s.
ErrorDiscountAlreadyUsed=Error, discount already used
ErrorInvoiceAvoirMustBeNegative=Error, correct invoice must have a negative amount
ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have a positive amount
+ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice that has been replaced by another invoice that is still in draft status
BillFrom=From
BillTo=Bill to
ActionsOnBill=Actions on invoice
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang
index d927efc9c9e..11dca0f602e 100644
--- a/htdocs/langs/fr_FR/bills.lang
+++ b/htdocs/langs/fr_FR/bills.lang
@@ -90,10 +90,11 @@ ErrorVATIntraNotConfigured=Num
ErrorNoPaiementModeConfigured=Aucun mode de règlement défini
ErrorCreateBankAccount=Créer un compte bancaire puis aller dans la configuration du module facture pour définir les modes de règlement
ErrorBillNotFound=Facture %s inexistante
-ErrorInvoiceAlreadyReplaced=Erreur, la facture %s a déjà été remplacée par la facture %s
+ErrorInvoiceAlreadyReplaced=Erreur, vous voulez valider une facture qui doit remplacer la facture %s. Mais cette dernière a déjà été remplacée par une autre facture %s.
ErrorDiscountAlreadyUsed=Erreur, la remise a déjà été attribuée
ErrorInvoiceAvoirMustBeNegative=Erreur, une facture de type Avoir doit avoir un montant négatif
ErrorInvoiceOfThisTypeMustBePositive=Erreur, une facture de ce type doit avoir un montant positif
+ErrorCantCancelIfReplacementInvoiceNotValidated=Erreur, il n'est pas possible d'annuler une facture qui a été remplacée par une autre qui se trouve toujours à l'état 'brouillon'.
BillFrom=Émetteur
BillTo=Adressé à
ActionsOnBill=Actions sur la facture