From e22925d59e52947df19641b53f70446f9747c8ae Mon Sep 17 00:00:00 2001 From: "Walid HANNICHE (waha)" Date: Fri, 2 Sep 2022 14:29:56 +0000 Subject: [PATCH] [FIX] account: fix resquence with empty journal name Steps to reproduce: - Accounting > journal entries > misc - add entries (draft) with empty journal name - resquence those entries with entries that have names Bug: calling min or sort on the names fails when some are strings and others are bools (False for empty strings) Fix: replace names that aren't set with an empty strings opw-2957750 closes odoo/odoo#99772 X-original-commit: 0f90852818a334d66ed8a6781f5abdc022f76ff7 Signed-off-by: Grazioso Andrea (agr) --- addons/account/wizard/account_resequence.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/wizard/account_resequence.py b/addons/account/wizard/account_resequence.py index 992592b9d53..a3d60d37f06 100644 --- a/addons/account/wizard/account_resequence.py +++ b/addons/account/wizard/account_resequence.py @@ -55,7 +55,7 @@ class ReSequenceWizard(models.TransientModel): self.first_name = "" for record in self: if record.move_ids: - record.first_name = min(record.move_ids._origin.mapped('name')) + record.first_name = min(record.move_ids._origin.mapped(lambda move: move.name or "")) @api.depends('new_values', 'ordering') def _compute_preview_moves(self): @@ -128,7 +128,7 @@ class ReSequenceWizard(models.TransientModel): for move, new_name in zip(period_recs.sorted(lambda m: (m.sequence_prefix, m.sequence_number)), new_name_list): new_values[move.id]['new_by_name'] = new_name # For all the moves of this period, assign the name by increasing date - for move, new_name in zip(period_recs.sorted(lambda m: (m.date, m.name, m.id)), new_name_list): + for move, new_name in zip(period_recs.sorted(lambda m: (m.date, m.name or "", m.id)), new_name_list): new_values[move.id]['new_by_date'] = new_name record.new_values = json.dumps(new_values)