[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.
This commit is contained in:
Xavier Morel
2017-06-12 11:04:23 +02:00
parent a5283f90ce
commit ba1b88db34
+7 -7
View File
@@ -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')