From 47fdb1a641cd835a93b7d353ba70590bb2990a4a Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Thu, 7 Dec 2023 11:46:38 +0100 Subject: [PATCH] [FIX] joint_buying_base : avoid bad order on tour report, if stop quantity >= 10 --- joint_buying_base/models/joint_buying_tour.py | 13 +++++++++---- .../reports/report_joint_buying_tour.xml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/joint_buying_base/models/joint_buying_tour.py b/joint_buying_base/models/joint_buying_tour.py index a7391ef6..417b16de 100644 --- a/joint_buying_base/models/joint_buying_tour.py +++ b/joint_buying_base/models/joint_buying_tour.py @@ -350,8 +350,9 @@ def button_see_transport_requests(self): def get_report_data(self): def key(item): + len_max_sequence = len(str(item["handling_max_sequence"])) return ( - str(item["handling_sequence"]) + str(item["handling_sequence"]).rjust(len_max_sequence, "0") + "-" + str(item["action_type"]) + "-" @@ -360,20 +361,24 @@ def key(item): + str(item["recipient_partner"]) ) - def _prepare_base_data(transport_request_line): + def _prepare_base_data(transport_request_line, max_sequence): return { "request_line_id": transport_request_line.id, + "handling_max_sequence": max_sequence, } self.ensure_one() res = [] sequence = 0 + max_sequence = ( + len(self.line_ids.filtered(lambda x: x.sequence_type == "journey")) + 1 + ) for tour_line in self.line_ids.filtered(lambda x: x.sequence_type == "journey"): sequence += 1 for transport_request_line in tour_line.transport_request_line_ids: # Loading data if transport_request_line.start_action_type == "loading": - base_data = _prepare_base_data(transport_request_line) + base_data = _prepare_base_data(transport_request_line, max_sequence) base_data.update( { "handling_sequence": sequence, @@ -388,7 +393,7 @@ def _prepare_base_data(transport_request_line): line_data.update(base_data) res.append(line_data) if transport_request_line.arrival_action_type == "unloading": - base_data = _prepare_base_data(transport_request_line) + base_data = _prepare_base_data(transport_request_line, max_sequence) base_data.update( { "handling_sequence": sequence + 1, diff --git a/joint_buying_base/reports/report_joint_buying_tour.xml b/joint_buying_base/reports/report_joint_buying_tour.xml index 179cbea4..27e1d6dd 100644 --- a/joint_buying_base/reports/report_joint_buying_tour.xml +++ b/joint_buying_base/reports/report_joint_buying_tour.xml @@ -15,7 +15,7 @@

- / - + / -