From c943b4cd33ad5be87dae77ad91c2a1172d49dd97 Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 14 Sep 2018 17:46:15 +0200 Subject: [PATCH 1/2] [FIX] keep the order line sorted when creating the layout_lines dict --- sale_usability/sale.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sale_usability/sale.py b/sale_usability/sale.py index cde4629..6408ec0 100644 --- a/sale_usability/sale.py +++ b/sale_usability/sale.py @@ -4,6 +4,7 @@ from odoo import models, fields, api from odoo.tools import float_is_zero +from collections import OrderedDict class SaleOrder(models.Model): @@ -55,7 +56,7 @@ class SaleOrder(models.Model): @api.multi def py3o_lines_layout(self): self.ensure_one() - res1 = {} + res1 = OrderedDict() # {categ(6): {'lines': [l1, l2], 'subtotal': 23.32}} for line in self.order_line: categ = line.layout_category_id From 118dd2a5c02d4853405c13990c8edc97254bd59e Mon Sep 17 00:00:00 2001 From: Benoit Date: Fri, 28 Sep 2018 17:42:31 +0200 Subject: [PATCH 2/2] [FIX] keep invoice lines sorted when creating the layout_lines dict --- sale_usability/account_invoice.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sale_usability/account_invoice.py b/sale_usability/account_invoice.py index 0bf27b8..a7d7acc 100644 --- a/sale_usability/account_invoice.py +++ b/sale_usability/account_invoice.py @@ -4,6 +4,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models +from collections import OrderedDict class AccountInvoice(models.Model): @@ -15,7 +16,7 @@ class AccountInvoice(models.Model): # https://github.com/akretion/odoo-py3o-report-templates/tree/10.0/account_invoice_report_py3o def py3o_lines_layout(self): self.ensure_one() - res1 = {} + res1 = OrderedDict() # {'categ(6)': {'lines': [l1, l2], 'subtotal': 23.32}} for line in self.invoice_line_ids: categ = line.layout_category_id @@ -52,7 +53,7 @@ class AccountInvoice(models.Model): # defined above: you just have to change the call in the invoice # ODT template self.ensure_one() - res1 = {} + res1 = OrderedDict() # {categ(1): {'lines': [l1, l2], 'subtotal': 23.32}} soo = self.env['sale.order'] for line in self.invoice_line_ids: