From 16cbbf96b9fcbca874cd8a14527a5fb710c6ec05 Mon Sep 17 00:00:00 2001 From: higo-odoo Date: Tue, 16 Aug 2022 11:44:41 +0000 Subject: [PATCH] [FIX] purchase_requisition,purchase_requisition_stock: Fix Test case How to reproduce the problem: - Install the purchase_requistion, purchase_requistion_stock, and any Localization modules such as l10n_be or l10n_in (apart from USD currency any localization module) - error caught only when at the time of module installation but it must have a different currency_id apart from USD https://watch.screencastify.com/v/1C7GQKHBASyiluGGkFfV Cause of the problem: static values Currency USD cause the problem. the following module will be set the currency value l10n_be - EUR l10n_in - INR l10n_br - BRL when we installed the following modules then cls.env.user.company_id.currency_id values get changes accordingly will lead to this error Traceback (most recent call last): File /home/odoo/src/odoo/addons/purchase_requisition/tests/common.py, line 70, in setUpClass cls.env.user.company_id.currency_id = cls.env.ref(base.USD).id File /home/odoo/src/odoo/odoo/fields.py, line 1217, in __set__ records.write({self.name: write_value}) File /home/odoo/src/odoo/addons/account/models/company.py, line 301, in write raise UserError(_('You cannot change the currency of the company since some journal items already exist')) odoo.exceptions.UserError: You cannot change the currency of the company since some journal items already exist opw-2945581 closes odoo/odoo#98512 Closes: https://github.com/odoo/odoo/pull/98174 X-original-commit: 70b7c57f7ea0a619a149461e0e738ddc25b822f6 Signed-off-by: William Henrotin (whe) --- addons/purchase_requisition/tests/common.py | 1 - .../tests/test_purchase_requisition_stock.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/purchase_requisition/tests/common.py b/addons/purchase_requisition/tests/common.py index 67072441d6b..ffa9cb2e35d 100644 --- a/addons/purchase_requisition/tests/common.py +++ b/addons/purchase_requisition/tests/common.py @@ -66,4 +66,3 @@ class TestPurchaseRequisitionCommon(common.TransactionCase): cls.res_partner_1 = cls.env['res.partner'].create({ 'name': 'Wood Corner', }) - cls.env.user.company_id.currency_id = cls.env.ref("base.USD").id diff --git a/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py b/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py index 738eb40f651..15a2de173cc 100644 --- a/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py +++ b/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py @@ -58,7 +58,7 @@ class TestPurchaseRequisitionStock(TestPurchaseRequisitionCommon): 'line_ids': [line1], 'type_id': requisition_type.id, 'vendor_id': vendor2.id, - 'currency_id': self.env.ref("base.USD").id, + 'currency_id': self.env.user.company_id.currency_id.id, }) requisition_blanket.action_in_progress() @@ -144,13 +144,13 @@ class TestPurchaseRequisitionStock(TestPurchaseRequisitionCommon): 'line_ids': [line1], 'type_id': requisition_type.id, 'vendor_id': vendor1.id, - 'currency_id': self.env.ref("base.USD").id, + 'currency_id': self.env.user.company_id.currency_id.id, }) requisition_2 = self.env['purchase.requisition'].create({ 'line_ids': [line2], 'type_id': requisition_type.id, 'vendor_id': vendor1.id, - 'currency_id': self.env.ref("base.USD").id, + 'currency_id': self.env.user.company_id.currency_id.id, }) requisition_1.action_in_progress() requisition_2.action_in_progress()