From ba1b88db34333d65e0a6abdbc7904a03baaa361b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 29 May 2017 16:51:44 +0200 Subject: [PATCH] [FIX] P3: sales tests relying on dict iteration order test_00_sale_stock_invoice would blow up in Python 3, because the test(s) relies on the iteration order of the products dict to know where which line is (holy mother of caca) an set the relevant line's data by indexing directly into it. This would fail (with very odd results) in Python 2 and 3 as it could set information on the "wrong" order line aka the order line for a different product (and invoicing mode/whatever) than intended. Fix the issue by hard-coding the products iteration order (to the iteration order I get in Python 2.7.10 on that dict literal) using an OrderedDict. --- addons/sale/tests/test_sale_common.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/sale/tests/test_sale_common.py b/addons/sale/tests/test_sale_common.py index 85ecdeac108..ebea8f85c5f 100644 --- a/addons/sale/tests/test_sale_common.py +++ b/addons/sale/tests/test_sale_common.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. - +from collections import OrderedDict from odoo.addons.account.tests.account_test_classes import AccountingTestCase @@ -27,11 +27,11 @@ class TestSale(AccountingTestCase): 'groups_id': [(6, 0, [group_user.id])] }) # create quotation with differend kinds of products (all possible combinations) - self.products = { - 'prod_order': self.env.ref('product.product_order_01'), - 'prod_del': self.env.ref('product.product_delivery_01'), - 'serv_order': self.env.ref('product.service_order_01'), - 'serv_del': self.env.ref('product.service_delivery'), - } + self.products = OrderedDict([ + ('prod_order', self.env.ref('product.product_order_01')), + ('serv_del', self.env.ref('product.service_delivery')), + ('serv_order', self.env.ref('product.service_order_01')), + ('prod_del', self.env.ref('product.product_delivery_01')), + ]) self.partner = self.env.ref('base.res_partner_1')