From 77c41cc5cb64a951789d251b445f05e42cf1b997 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu <chm@odoo.com> Date: Thu, 25 Sep 2014 15:32:25 +0200 Subject: [PATCH] [FIX] website: 'Display Editor Bar on Website' group stopped working at commit a2ef044c477 The Edit button never appeared anymore for these users. The idea was that they should see an edit button with limited editing capabilities depending on their other access rights. For example, someone with only Sales Manager access and 'Display Editor Bar on Website' would be able to edit online quotes from the website_quote module, but not change the actual website pages or menus, for instance. --- addons/website/models/ir_ui_view.py | 5 ++++- addons/website/static/src/js/website.editor.js | 10 +--------- addons/website/static/src/js/website.js | 5 +++-- addons/website/views/website_backend_navbar.xml | 4 ++-- openerp/addons/base/ir/ir_qweb.py | 6 +++++- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index da9de182eb83..ebb1753a1897 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -159,7 +159,10 @@ class view(osv.osv): qcontext.update(values) # in edit mode ir.ui.view will tag nodes - context = dict(context, inherit_branding=qcontext.get('editable', False)) + if qcontext.get('editable'): + context = dict(context, inherit_branding=True) + elif request.registry['res.users'].has_group(cr, uid, 'base.group_website_publisher'): + context = dict(context, inherit_branding_auto=True) view_obj = request.website.get_template(id_or_xml_id) if 'main_object' not in qcontext: diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index ee6368ea5aa0..82888c5d8a39 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -308,7 +308,6 @@ this.$('#website-top-edit').hide(); this.$('#website-top-view').show(); - this.$buttons.edit.show(); var $edit_button = this.$buttons.edit .prop('disabled', website.no_editor); @@ -822,14 +821,7 @@ return $(root).find('[data-oe-model]') .not('[data-oe-type = "selection"]') .not('link, script') - .not('.oe_snippet_editor') - .filter(function () { - var $this = $(this); - // keep view sections and fields which are *not* in - // view sections for top-level editables - return $this.data('oe-model') === 'ir.ui.view' - || !$this.closest('[data-oe-model = "ir.ui.view"]').length; - }); + .not('.oe_snippet_editor'); }, _current_editor: function () { diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 76756c08e477..be99c8e7221b 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -282,8 +282,9 @@ return templates_def; }).then(function () { // display button if they are at least one editable zone in the page (check the branding) - var editable = $('html').data('website-id') && !!$('[data-oe-model]').size(); - $("#oe_editzone").toggle(editable); + if (!!$('[data-oe-model]').size()) { + $("#oe_editzone").show(); + } if ($('html').data('website-id')) { website.id = $('html').data('website-id'); diff --git a/addons/website/views/website_backend_navbar.xml b/addons/website/views/website_backend_navbar.xml index d30e5415be18..820248d2b58e 100644 --- a/addons/website/views/website_backend_navbar.xml +++ b/addons/website/views/website_backend_navbar.xml @@ -25,8 +25,8 @@ </li> </ul> - <ul id="oe_editzone" class="nav navbar-nav hidden-xs" style="padding-left: 20px;" groups="base.group_website_publisher"> - <li><button type="button" data-action="edit" class="btn btn-primary btn-xs" style="display: none;">Edit</button></li> + <ul id="oe_editzone" class="nav navbar-nav hidden-xs" style="padding-left: 20px; display: none;" groups="base.group_website_publisher"> + <li><button type="button" data-action="edit" class="btn btn-primary btn-xs">Edit</button></li> </ul> <ul id="oe_systray" class="nav navbar-nav navbar-right pull-right hidden-xs"> diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index c244fe2d9721..d27d15b76f44 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -555,7 +555,11 @@ class FieldConverter(osv.AbstractModel): field_name, record._name, exc_info=True) content = None - if context and context.get('inherit_branding'): + inherit_branding = context and context.get('inherit_branding') + if not inherit_branding and context and context.get('inherit_branding_auto'): + inherit_branding = self.pool['ir.model.access'].check(cr, uid, record._name, 'write', False, context=context) + + if inherit_branding: # add branding attributes g_att += ''.join( ' %s="%s"' % (name, escape(value)) -- GitLab