From a98c752d688f5fa65d8d0dffac4b5031bd0268ec Mon Sep 17 00:00:00 2001 From: Carlos Roca Date: Wed, 20 Dec 2023 11:27:49 +0100 Subject: [PATCH] [IMP] account_invoice_report_grouped_by_picking: Add possibility to set custom order at lines --- .../models/account_move.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/account_invoice_report_grouped_by_picking/models/account_move.py b/account_invoice_report_grouped_by_picking/models/account_move.py index cf211aeb3..292db053f 100644 --- a/account_invoice_report_grouped_by_picking/models/account_move.py +++ b/account_invoice_report_grouped_by_picking/models/account_move.py @@ -46,7 +46,7 @@ def _process_section_note_lines_grouped( if previous_note and key_note not in lines_dic: lines_dic[key_note] = 0.0 - def lines_grouped_by_picking(self): + def lines_grouped_by_picking(self, sorted_lines=False): """This prepares a data structure for printing the invoice report grouped by pickings.""" self.ensure_one() @@ -69,9 +69,11 @@ def lines_grouped_by_picking(self): so_dict = {x.sale_id: x for x in self.picking_ids if x.sale_id} # Now group by picking by direct link or via same SO as picking's one previous_section = previous_note = False - for line in self.invoice_line_ids.sorted( - lambda ln: (-ln.sequence, ln.date, ln.move_name, -ln.id), reverse=True - ): + if not sorted_lines: + sorted_lines = self.invoice_line_ids.sorted( + lambda ln: (-ln.sequence, ln.date, ln.move_name, -ln.id), reverse=True + ) + for line in sorted_lines: if line.display_type == "line_section": previous_section = line continue