From dda18249c0fa1b2ac9d6eb39bc7397b71fb26c81 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 17 Jun 2014 12:22:15 +0200 Subject: [PATCH] [FIX] @groups attribute should not disappear when editing The @groups attribute in qweb views was not rendered (even when matched by the user), so editing a template with an @groups would either remove the whole section (if the user didn't have the groups, fixed in previous commit) or only removed the attribute itself making it visible to everybody (which ought be fixed-ish by this commit). --- addons/website/static/src/js/website.editor.js | 6 +++--- openerp/addons/base/ir/ir_qweb.py | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index f8d1a66bc80..601d3016068 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -497,11 +497,11 @@ this.$('#website-top-edit').hide(); this.$('#website-top-view').show(); + var $edit_button = this.$('button[data-action=edit]') + .prop('disabled', website.no_editor); if (website.no_editor) { var help_text = $(document.documentElement).data('editable-no-editor'); - this.$('button[data-action=edit]') - .prop('disabled', website.no_editor) - .parent() + $edit_button.parent() // help must be set on form above button because it does // not appear on disabled button .attr('title', help_text); diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 5fb56a2b4a3..1209e457958 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -256,15 +256,14 @@ class QWeb(orm.AbstractModel): cr = qwebcontext.get('request') and qwebcontext['request'].cr or None uid = qwebcontext.get('request') and qwebcontext['request'].uid or None can_see = self.user_has_groups(cr, uid, groups=attribute_value) if cr and uid else False - if can_see: - continue - if qwebcontext.get('editable') and not qwebcontext.get('editable_no_editor'): - errmsg = _("Editor disabled because some content can not be seen by a user who does not belong to the groups %s") - raise openerp.http.Retry( - _("User does not belong to groups %s") % attribute_value, { - 'editable_no_editor': errmsg % attribute_value - }) - return '' + if not can_see: + if qwebcontext.get('editable') and not qwebcontext.get('editable_no_editor'): + errmsg = _("Editor disabled because some content can not be seen by a user who does not belong to the groups %s") + raise openerp.http.Retry( + _("User does not belong to groups %s") % attribute_value, { + 'editable_no_editor': errmsg % attribute_value + }) + return '' if isinstance(attribute_value, unicode): attribute_value = attribute_value.encode("utf8")