Skip to content

Commit

Permalink
[FIX] joint_buying_base : avoid bad order on tour report, if stop qua…
Browse files Browse the repository at this point in the history
…ntity >= 10
  • Loading branch information
legalsylvain committed Dec 7, 2023
1 parent ea6ec67 commit 47fdb1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions joint_buying_base/models/joint_buying_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
+ "-"
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion joint_buying_base/reports/report_joint_buying_tour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<t t-set="product_category" t-value="" />
<hr size="3"/>
<h3>
<span t-esc="handling_sequence" /> / <span t-esc="doc.stop_qty + 2" /> -
<span t-esc="handling_sequence" /> / <span t-esc="data_item['handling_max_sequence']" /> -
<span t-esc="data_item['handling_partner'].name"/>
</h3>
<hr size="3"/>
Expand Down

0 comments on commit 47fdb1a

Please sign in to comment.