[FIX] base_setup: Default Access Rights

Prevent crash in case `base.default_user` has been deleted.

Note that the user shouldn't be deleted in a first place, but that's
another discussion...

opw-2360615

closes odoo/odoo#60821

X-original-commit: 7342cadcfe8d85edb8a53aef0ecc402dbbc7e935
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-10-27 12:54:49 +00:00
parent 60e165e60b
commit 77d3c1e8fe
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import UserError
class ResConfigSettings(models.TransientModel):
@@ -62,7 +63,10 @@ class ResConfigSettings(models.TransientModel):
def open_default_user(self):
action = self.env["ir.actions.actions"]._for_xml_id("base.action_res_users")
action['res_id'] = self.env.ref('base.default_user').id
if self.env.ref('base.default_user', raise_if_not_found=False):
action['res_id'] = self.env.ref('base.default_user').id
else:
raise UserError(_("Default User Template not found."))
action['views'] = [[self.env.ref('base.view_users_form').id, 'form']]
return action