From 8b5392f8e63c257514fd9d540834bd2fbbecfb1d Mon Sep 17 00:00:00 2001 From: JF Aubert Date: Mon, 27 Sep 2021 12:53:56 +0000 Subject: [PATCH] [FIX] sale_stock_margin: fix test_so_and_multicurrency failing around midnight Due to res currency date in user timezone and sale order date in utc. closes odoo/odoo#77283 X-original-commit: 34ce921ee1792dbe498fdab96808f76a5c336323 Signed-off-by: Arnold Moyaux Signed-off-by: Christophe Monniez (moc) --- addons/sale_stock_margin/tests/test_sale_stock_margin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/sale_stock_margin/tests/test_sale_stock_margin.py b/addons/sale_stock_margin/tests/test_sale_stock_margin.py index f96816e5383..6028756fcc6 100644 --- a/addons/sale_stock_margin/tests/test_sale_stock_margin.py +++ b/addons/sale_stock_margin/tests/test_sale_stock_margin.py @@ -171,12 +171,13 @@ class TestSaleStockMargin(TestStockValuationCommon): company_currency = self.env.company.currency_id other_currency = self.env.ref('base.EUR') if company_currency == self.env.ref('base.USD') else self.env.ref('base.USD') - ResCurrencyRate.create({'currency_id': company_currency.id, 'rate': 1}) - other_currency_rate = ResCurrencyRate.search([('name', '=', fields.Date.today()), ('currency_id', '=', other_currency.id)]) + date = fields.Date.today() + ResCurrencyRate.create({'currency_id': company_currency.id, 'rate': 1, 'name': date}) + other_currency_rate = ResCurrencyRate.search([('name', '=', date), ('currency_id', '=', other_currency.id)]) if other_currency_rate: other_currency_rate.rate = 2 else: - ResCurrencyRate.create({'currency_id': other_currency.id, 'rate': 2}) + ResCurrencyRate.create({'currency_id': other_currency.id, 'rate': 2, 'name': date}) so = self._create_sale_order() so.pricelist_id = self.env['product.pricelist'].create({