[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).
This commit is contained in:
Xavier Morel 2014-06-17 12:22:15 +02:00
parent 79e10200d5
commit dda18249c0
2 changed files with 11 additions and 12 deletions

View File

@ -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);

View File

@ -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")