[FIX] delivery: avoid tests to fail with l10n_*

The problem is that the cache still thinks in the test that
it is in EUR and then it does a currency conversion for calculating the
delivery cost and the test will fail in L105 of test_delivery_stock.py

By invalidating the cache after the sql that change the currency of the
company, we solve it.
(someone should refactor those tests though)

closes odoo/odoo#67790

X-original-commit: f0a1e7c35bd8cd17149d1d54bfe5b9eec12a0814
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
Josse Colpaert
2021-03-12 20:45:15 +00:00
parent 63d73e7034
commit 65fe57bd20
4 changed files with 7 additions and 4 deletions
+4 -1
View File
@@ -44,9 +44,11 @@ class TestDeliveryCost(common.TransactionCase):
self.free_delivery = self.env.ref('delivery.free_delivery_carrier')
# as the tests hereunder assume all the prices in USD, we must ensure
# that the company actually uses USD
# We do an invalidate_cache so the cache is aware of it too.
self.env.cr.execute(
"UPDATE res_company SET currency_id = %s WHERE id = %s",
[self.env.ref('base.USD').id, self.env.company.id])
self.env.company.invalidate_cache()
self.pricelist.currency_id = self.env.ref('base.USD').id
def test_00_delivery_cost(self):
@@ -102,8 +104,9 @@ class TestDeliveryCost(common.TransactionCase):
('product_id', '=', self.normal_delivery.product_id.id)])
self.assertEqual(len(line), 1, "Delivery cost is not Added")
zin = str(delivery_wizard.display_price) + " " + str(delivery_wizard.delivery_price) + ' ' + line.company_id.country_id.code + line.company_id.name
self.assertEqual(float_compare(line.price_subtotal, 10.0, precision_digits=2), 0,
"Delivery cost is not correspond.")
"Delivery cost does not correspond to 10.0. %s %s" % (line.price_subtotal, zin))
# I confirm the sales order
+1 -1
View File
@@ -14,4 +14,4 @@ def _create_picking_seq(cr, registry):
'prefix': wh.code + '/' + ptype.sequence_code + '/DDT', 'padding': 5,
'company_id': wh.company_id.id,
'implementation': 'no_gap',
}).id
}).id
+1 -1
View File
@@ -2,4 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import stock_picking
from . import account_invoice
from . import account_invoice
@@ -68,4 +68,4 @@ class StockPickingType(models.Model):
'name': ir_seq_name,
'prefix': ir_seq_prefix,
})
return super(StockPickingType, self).write(vals)
return super(StockPickingType, self).write(vals)