trytond.exceptions.UserError in rst file

Create Party::

>>> Party = Model.get('party.party')
>>> party = Party(name='john')
>>> party.save()
File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond_pay_automation-5.0.0-py3.8.egg/trytond/modules/pay_automation/tests/pay.rst", line 32, in pay.rst
Failed example:
    party.save()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.8/doctest.py", line 1336, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest pay.rst[13]>", line 1, in <module>
        party.save()
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/proteus/__init__.py", line 102, in newfunc
        return self.func(owner, [instance], *args, **kwargs)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/proteus/__init__.py", line 847, in save
        ids = proxy.create(values, context)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/proteus/config.py", line 188, in __call__
        result = rpc.result(meth(*args, **kwargs))
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/gnuhealth-3.6.5-py3.8.egg/trytond/modules/health/health.py", line 770, in create
        return super(Party, cls).create(vlist)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond/modules/party/party.py", line 186, in create
        return super(Party, cls).create(vlist)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond/model/modelsql.py", line 147, in wrapper
        return func(cls, *args, **kwargs)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond/model/modelsql.py", line 549, in create
        super(ModelSQL, cls).create(vlist)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond/model/modelstorage.py", line 104, in create
        ModelAccess.check(cls.__name__, 'create')
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond/ir/model.py", line 522, in check
        cls.raise_user_error(mode, model_name)
      File "/home/vam/workspace/tryton/tryton50/lib/python3.8/site-packages/trytond/error.py", line 74, in raise_user_error
        raise UserError(error)
    trytond.exceptions.UserError: You can not create this kind of document! (party.party) -

The error is raised beucase the user executing the rst file is not allowed to create party.

On tryton by default all users are allowed to create a party so it seems you have an access rule on your database which adds this restriction.

Adding the user to the proper group should fix the issue.

1 Like