FIX - Add validation for manufacturing order date changes (#36823)

* Add validation for manufacturing order date changes and update translations

* Fix indentation in manufacturing order date handling logic
This commit is contained in:
atm-corentin 2026-01-07 18:28:58 +01:00 committed by GitHub
parent 103d350fb8
commit 224aab4265
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 26 deletions

View file

@ -165,8 +165,10 @@ ModifyDateEnd = New planned end date
ModifyMoDate = Date modification validated for %s
ErrorEmptyChangeDate = Please define a date
ConfirmMassChangeDateEnd = Confirmation of mass modification of the planned end date
ErrorModifyMoDateStart = You must choose a start date earlier than the current start date. %s
ErrorModifyMoDateStart = You must choose a start date earlier than the current end date. %s
ErrorModifyMoDateEnd = You must choose an end date later than the start date. %s
ErrorCancelMo=Error updating cancellation
ErrorModifyMoDate=Error updating date modification
ErrorObjectMustNotBeFinishedToModifyDateEnd = Object %s must not be finished to modify the end date.
ErrorObjectMustNotBeFinishedToModifyDateStart = Object %s must not be finished to modify the start date.
UseSearchToSelectBom=Wait until a key is pressed before loading content of Boms combo list.<br>This may improve performance if you have a large number of projects, but it is less convenient.

View file

@ -165,8 +165,10 @@ ModifyDateEnd = Nouvelle date de fin prévue
ModifyMoDate = Modification de la date validée pour %s
ErrorEmptyChangeDate = Veuillez définir une date
ConfirmMassChangeDateEnd = Confirmation de la modification massive de la date de fin prévue
ErrorModifyMoDateStart = Vous devez choisir une date de début antérieure à la date de début actuelle. %s
ErrorModifyMoDateStart = Vous devez choisir une date de début antérieure à la date de fin actuelle. %s
ErrorModifyMoDateEnd = Vous devez choisir une date de fin postérieure à la date de début. %s
ErrorCancelMo=Erreur lors de la mise à jour de l'annulation
ErrorModifyMoDate=Erreur lors de la mise à jour de la modification de la date
UseSearchToSelectBom=Attendre que vous ayez appuyé sur une touche avant de charger le contenu de la liste déroulante des nomenclatures (Cela peut augmenter les performances si vous avez un grand nombre de nomenclatures, mais cela est moins convivial)
ErrorObjectMustNotBeFinishedToModifyDateEnd = L'objet %s ne doit pas être fabriqué pour modifier la date de fin.
ErrorObjectMustNotBeFinishedToModifyDateStart = L'objet %s ne doit pas être fabriqué pour modifier la date de début.
UseSearchToSelectBom=Attendre que vous ayez appuyé sur une touche avant de charger le contenu de la liste déroulante des nomenclatures (Cela peut augmenter les performances si vous avez un grand nombre de nomenclatures, mais cela est moins convivial)

View file

@ -253,34 +253,37 @@ if (empty($reshook)) {
if (!empty($toselect)) {
foreach ($toselect as $key => $idMo) {
if ($objMo->fetch($idMo)) {
if ($objMo->status == Mo::STATUS_DRAFT) {
if (!empty($changeDate)) {
if ($action == 'changedatestart_confirm') { // Test on permission not required
if ($newDate < $objMo->date_end_planned) {
$objMo->date_start_planned = $newDate;
} else {
setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
break;
}
} elseif ($action == 'changedateend_confirm') { // Test on permission not required
if ($newDate > $objMo->date_start_planned) {
$objMo->date_end_planned = $newDate;
} else {
setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
break;
}
}
if ($objMo->update($user)) {
setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
if (in_array($action, array('changedatestart_confirm', 'changedateend_confirm'), true) && $objMo->status == Mo::STATUS_PRODUCED) {
$errorKey = $action == 'changedatestart_confirm'
? 'ErrorObjectMustNotBeFinishedToModifyDateStart'
: 'ErrorObjectMustNotBeFinishedToModifyDateEnd';
setEventMessages($langs->trans($errorKey, $objMo->ref), null, 'errors');
continue;
}
if (!empty($changeDate)) {
if ($action == 'changedatestart_confirm') { // Test on permission not required
if (empty($objMo->date_end_planned) || $newDate < $objMo->date_end_planned) {
$objMo->date_start_planned = $newDate;
} else {
setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
break;
}
} elseif ($action == 'changedateend_confirm') { // Test on permission not required
if ($newDate > $objMo->date_start_planned) {
$objMo->date_end_planned = $newDate;
} else {
setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
break;
}
}
if ($objMo->update($user)) {
setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
} else {
setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
break;
setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
}
} else {
setEventMessages($langs->trans('ErrorObjectMustHaveStatusDraftToModifyDate', $objMo->ref), null, 'errors');
setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
break;
}
}
}