[FIX] sale: fix test_pricelist_dates

This test is failling during nightly mainly when executed arround 23

The most likely reason for that is because of the freezetime rounding
the day and creating an error between 23 and 00.

The freezetime only wraps the create but the compute will be triggered
only after that. Adding all assertions inside the freezetime may be
enough to fix this issue.

closes odoo/odoo#101989

X-original-commit: 98693d5543e3c0b4f8f51a05e026fce8ddb77a51
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Xavier-Do
2022-10-04 10:55:41 +02:00
parent 150951f61b
commit 6df3ffb81d
+14 -13
View File
@@ -124,17 +124,18 @@ class TestSalePrices(SaleCommon):
self.assertEqual(order_line.discount, 0.0)
self.empty_order.date_order = False
with freeze_time(today):
order_line = self.env['sale.order.line'].create({
'order_id': self.empty_order.id,
'product_id': self.product.id,
})
self.assertEqual(order_line.pricelist_item_id, pricelist_rule)
self.assertEqual(
order_line.price_unit,
self.product.lst_price * (1 - self.discount / 100.0))
self.assertEqual(order_line.discount, 0.0)
self.assertEqual(order_line.pricelist_item_id, pricelist_rule)
self.assertEqual(
order_line.price_unit,
self.product.lst_price * (1 - self.discount / 100.0))
self.assertEqual(order_line.discount, 0.0)
with freeze_time(tomorrow):
order_line = self.env['sale.order.line'].create({
@@ -142,15 +143,15 @@ class TestSalePrices(SaleCommon):
'product_id': self.product.id,
})
self.assertEqual(order_line.pricelist_item_id, pricelist_rule)
self.assertEqual(
order_line.price_unit,
self.product.lst_price)
self.assertEqual(order_line.discount, 0.0)
self.assertEqual(order_line.pricelist_item_id, pricelist_rule)
self.assertEqual(
order_line.price_unit,
self.product.lst_price)
self.assertEqual(order_line.discount, 0.0)
self.assertEqual(
self.empty_order.amount_untaxed,
self.product.lst_price * 3.8)
self.assertEqual(
self.empty_order.amount_untaxed,
self.product.lst_price * 3.8)
def test_pricelist_product_context(self):
""" Verify that the product attributes extra prices are correctly considered """