From 8f1eb6941082c13f81d7e44441ec580a50c17d68 Mon Sep 17 00:00:00 2001 From: "Habib (ayh)" Date: Tue, 25 May 2021 14:03:48 +0000 Subject: [PATCH] [IMP] account: improve error message of mismatched date and sequence number The error message when resetting a payment to draft and changing the date is not adequate. This aims to guide the user to the appropiate journal entry where changes are required. part 2 of task [2533660] closes odoo/odoo#73470 Signed-off-by: Laurent Smet --- addons/account/models/sequence_mixin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/account/models/sequence_mixin.py b/addons/account/models/sequence_mixin.py index 60d4195d797..bf84c468579 100644 --- a/addons/account/models/sequence_mixin.py +++ b/addons/account/models/sequence_mixin.py @@ -63,12 +63,14 @@ class SequenceMixin(models.AbstractModel): or format_values['month'] and format_values['month'] != date.month ): raise ValidationError(_( - "The %(date_field)s (%(date)s) doesn't match the %(sequence_field)s (%(sequence)s).\n" - "You might want to clear the field %(sequence_field)s before proceeding with the change of the date.", + "The %(date_field)s (%(date)s) doesn't match the sequence number of the related %(model)s (%(sequence)s)\n" + "You will need to clear the %(model)s's %(sequence_field)s to proceed.\n" + "In doing so, you might want to resequence your entries in order to maintain a continuous date-based sequence.", date=format_date(self.env, date), sequence=sequence, date_field=record._fields[record._sequence_date_field]._description_string(self.env), sequence_field=record._fields[record._sequence_field]._description_string(self.env), + model=self.env['ir.model']._get(record._name).display_name, )) @api.depends(lambda self: [self._sequence_field])