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

[15.0][IMP] account_invoice_report_grouped_by_picking: Add possibility to set custom order at lines #299

Merged
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
10 changes: 7 additions & 3 deletions account_invoice_report_grouped_by_picking/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def _process_section_note_lines_grouped(
if previous_note and key_note not in lines_dic:
lines_dic[key_note] = 0.0

def _get_grouped_by_picking_sorted_lines(self):
return self.invoice_line_ids.sorted(
lambda ln: (-ln.sequence, ln.date, ln.move_name, -ln.id), reverse=True
)

def lines_grouped_by_picking(self):
"""This prepares a data structure for printing the invoice report
grouped by pickings."""
Expand All @@ -69,9 +74,8 @@ 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
):
sorted_lines = self._get_grouped_by_picking_sorted_lines()
for line in sorted_lines:
if line.display_type == "line_section":
previous_section = line
continue
Expand Down
Loading