From c2c856abd970d3afee71506006251ff2c72be04e Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Wed, 24 Apr 2024 11:41:36 +0200 Subject: [PATCH] [FIX] test_new_api: fix portal subtest without demo The test_sudo_commands fails when testing portal user without demo data. With this commit, a portal user is created in a setupClass. closes odoo/odoo#163319 Build-error: 55927 X-original-commit: 83c2201543d4d37b2d8e760200c5b111e1d74fa1 Signed-off-by: Xavier Morel (xmo) Signed-off-by: Christophe Monniez (moc) --- .../test_new_api/tests/test_new_fields.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/odoo/addons/test_new_api/tests/test_new_fields.py b/odoo/addons/test_new_api/tests/test_new_fields.py index da7a2f2534a..d087bd2ed9f 100644 --- a/odoo/addons/test_new_api/tests/test_new_fields.py +++ b/odoo/addons/test_new_api/tests/test_new_fields.py @@ -2923,6 +2923,26 @@ class TestFields(TransactionCaseWithUserDemo): class TestX2many(common.TransactionCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user_portal = cls.env['res.users'].sudo().search([('login', '=', 'portal')]) + cls.partner_portal = cls.user_portal.partner_id + + if not cls.user_portal: + cls.env['ir.config_parameter'].sudo().set_param('auth_password_policy.minlength', 4) + cls.partner_portal = cls.env['res.partner'].create({ + 'name': 'Joel Willis', + 'email': 'joel.willis63@example.com', + }) + cls.user_portal = cls.env['res.users'].with_context(no_reset_password=True).create({ + 'login': 'portal', + 'password': 'portal', + 'partner_id': cls.partner_portal.id, + 'groups_id': [Command.set([cls.env.ref('base.group_portal').id])], + }) + def test_definition_many2many(self): """ Test the definition of inherited many2many fields. """ field = self.env['test_new_api.multi.line']._fields['tags']