Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] joint_buying_base : avoid bad order on tour report, if stop quantity >= 10 #82

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading