From 2c27331a3e6bada6fcc82419504c5680d9d338d5 Mon Sep 17 00:00:00 2001 From: kobros-tech Date: Wed, 25 Dec 2024 00:15:27 +0300 Subject: [PATCH] [18.0][FIX] web_pivot_computed_measure: fix fake fields in tests --- web_pivot_computed_measure/README.rst | 4 +++ .../readme/CONTRIBUTORS.md | 4 +++ .../static/description/index.html | 4 +++ .../tests/res_users_fake.py | 12 ------- .../tests/test_ui_pivot.py | 36 +++++++++++++++---- 5 files changed, 41 insertions(+), 19 deletions(-) delete mode 100644 web_pivot_computed_measure/tests/res_users_fake.py diff --git a/web_pivot_computed_measure/README.rst b/web_pivot_computed_measure/README.rst index 5f895abf97cc..250aa9555d41 100644 --- a/web_pivot_computed_measure/README.rst +++ b/web_pivot_computed_measure/README.rst @@ -109,6 +109,10 @@ Contributors - Ernesto Tejeda - Carlos Roca +- `Kencove `__: + + - Mohamed Alkobrosli + Maintainers ----------- diff --git a/web_pivot_computed_measure/readme/CONTRIBUTORS.md b/web_pivot_computed_measure/readme/CONTRIBUTORS.md index 5d3768b54ddf..12a4cec67df2 100644 --- a/web_pivot_computed_measure/readme/CONTRIBUTORS.md +++ b/web_pivot_computed_measure/readme/CONTRIBUTORS.md @@ -3,3 +3,7 @@ - Pedro M. Baeza - Ernesto Tejeda - Carlos Roca + +- [Kencove](https://www.kencove.com/): + - Mohamed Alkobrosli + \ No newline at end of file diff --git a/web_pivot_computed_measure/static/description/index.html b/web_pivot_computed_measure/static/description/index.html index 203a83951fd0..9dc5012c2b0c 100644 --- a/web_pivot_computed_measure/static/description/index.html +++ b/web_pivot_computed_measure/static/description/index.html @@ -460,6 +460,10 @@

Contributors

  • Carlos Roca
  • +
  • Kencove:
      +
    • Mohamed Alkobrosli
    • +
    +
  • diff --git a/web_pivot_computed_measure/tests/res_users_fake.py b/web_pivot_computed_measure/tests/res_users_fake.py deleted file mode 100644 index 4561b79a9c58..000000000000 --- a/web_pivot_computed_measure/tests/res_users_fake.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2022 Tecnativa - Carlos Roca -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) - - -from odoo import fields, models - - -class ResUsersFake(models.Model): - _inherit = "res.users" - - user_year_born = fields.Integer() - user_year_now = fields.Integer() diff --git a/web_pivot_computed_measure/tests/test_ui_pivot.py b/web_pivot_computed_measure/tests/test_ui_pivot.py index 1dc01aebdaf7..603c318ed294 100644 --- a/web_pivot_computed_measure/tests/test_ui_pivot.py +++ b/web_pivot_computed_measure/tests/test_ui_pivot.py @@ -1,6 +1,5 @@ # Copyright 2022 Tecnativa - Carlos Roca # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) -from odoo_test_helper import FakeModelLoader from odoo.tests import common, tagged @@ -10,18 +9,41 @@ class TestUIPivot(common.HttpCase): @classmethod def setUpClass(cls): super().setUpClass() - cls.loader = FakeModelLoader(cls.env, cls.__module__) - cls.loader.backup_registry() - from .res_users_fake import ResUsersFake - cls.loader.update_registry((ResUsersFake,)) + res_users_model_id = ( + cls.env["ir.model"].search([("model", "=", "res.users")]).id + ) + cls.env["ir.model.fields"].create( + { + "name": "x_user_year_born", + "model": "res.users", + "field_description": "Year Born", + "ttype": "integer", + "store": False, + "model_id": res_users_model_id, + } + ) + cls.env["ir.model.fields"].create( + { + "name": "x_user_year_now", + "model": "res.users", + "field_description": "Year Born", + "ttype": "integer", + "store": False, + "model_id": res_users_model_id, + } + ) + cls.env.registry.setup_models(cls.env.cr) + cls.env.registry.init_models( + cls.env.cr, ["res.users"], {"update_custom_fields": True} + ) cls.env["res.users"].create( { "name": "User 1", "login": "us_1", # Fake fields - "user_year_born": 1998, - "user_year_now": 2022, + "x_user_year_born": 1998, + "x_user_year_now": 2022, } ) # Set pivot view to company action