Hello,
I used classic inheritance on 'res.users' model, to have some additional fields in user and I also have an additional method. Therefore, I would like to write a test for that method and would like to build a user only for the tests.
I was using the 'demo.xml' file since then, but I don’t think it is a good approach, since the actual users of the module will not use odoo in demonstration mode. So I’m afraid the demo.xml data won’t be accessible with the demonstration mode disabled.
So I tried this :
class TestResUsers(TransactionCase):
def setUp(self, *args, **kwargs):
super(TestResUsers, self).setUp(*args, **kwargs)
self.test_user = self.env['res.users'].create({
'name': 'test user',
})
But I get the following error, when the tests run :
ERROR
======================================================================
ERROR: test_get_client (odoo.addons.connector_trello.tests.test_res_users.TestTrelloUsers)
Traceback (most recent call last):
` File "/home/cyrille/odoo/addons-dev/connector_trello/tests/test_res_users.py", line 13, in setUp
` 'name': 'test user',
` File "/opt/odoo/odoo/addons/sales_team/models/res_users.py", line 17, in create
` user = super(ResUsers, self).create(vals)
` File "/opt/odoo/odoo/addons/auth_signup/models/res_users.py", line 154, in create
` user = super(ResUsers, self).create(values)
` File "/opt/odoo/odoo/addons/mail/models/res_users.py", line 55, in create
` raise exceptions.RedirectWarning(msg, action.id, _('Go to the configuration panel'))
` odoo.exceptions.RedirectWarning: ('You cannot create a new user from here.\n To create new user please go to configuration panel.', 65, 'Go to the configuration panel')
Apparently, I can’t create a user from the test environment. Is it an access right issue ? Is there another solution ?
Thanks.
@Yenthe Van Ginneken Indeed, it worked, thank you very much
You're welcome! Happy it helped.