From 8403e1c7fbb6c4baa0b15fe00f48253940e6557c Mon Sep 17 00:00:00 2001 From: sergiocorato Date: Thu, 16 May 2024 15:27:00 +0200 Subject: [PATCH] [FIX] sequence of account move lines --- .../models/account_move.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/account_invoice_section_sale_order/models/account_move.py b/account_invoice_section_sale_order/models/account_move.py index 80b54fc77c2..70b37d6e531 100644 --- a/account_invoice_section_sale_order/models/account_move.py +++ b/account_invoice_section_sale_order/models/account_move.py @@ -10,6 +10,15 @@ class AccountMove(models.Model): def _get_ordered_invoice_lines(self): """Sort invoice lines according to the section ordering""" + invoice_section_grouping = self.company_id.invoice_section_grouping + if invoice_section_grouping == "sale_order": + return self.invoice_line_ids.sorted( + key=lambda r: ( + f"{r.mapped('sale_line_ids.order_id.id')}" + f"{r.mapped('sale_line_ids.sequence')}" + f"{r.mapped('sale_line_ids.id')}" + ) + ) return self.invoice_line_ids.sorted( key=self.env["account.move.line"]._get_section_ordering() )