diff --git a/addons/website/models/website_form.py b/addons/website/models/website_form.py index 28bb2674ce4..b7a6ee295fe 100644 --- a/addons/website/models/website_form.py +++ b/addons/website/models/website_form.py @@ -68,6 +68,15 @@ class website_form_model(models.Model): return fields_get + @api.model + def get_compatible_form_models(self): + if not self.env.user.has_group('website.group_website_restricted_editor'): + return [] + return self.sudo().search_read( + [('website_form_access', '=', True)], + ['id', 'model', 'name', 'website_form_label', 'website_form_key'], + ) + class website_form_model_fields(models.Model): """ fields configuration for form builder """ diff --git a/addons/website/static/src/snippets/s_website_form/options.js b/addons/website/static/src/snippets/s_website_form/options.js index 452fb0ff6f3..6a9e800bf73 100644 --- a/addons/website/static/src/snippets/s_website_form/options.js +++ b/addons/website/static/src/snippets/s_website_form/options.js @@ -305,12 +305,8 @@ options.registry.WebsiteFormEditor = FormEditor.extend({ // Get list of website_form compatible models. this.models = await this._rpc({ - model: "ir.model", - method: "search_read", - args: [ - [['website_form_access', '=', true]], - ['id', 'model', 'name', 'website_form_label', 'website_form_key'] - ], + model: 'ir.model', + method: 'get_compatible_form_models', }); const targetModelName = this.$target[0].dataset.model_name || 'mail.mail';