[FIX] @groups attribute should not disappear when editing
authorXavier Morel <xmo@openerp.com>
Tue, 17 Jun 2014 10:22:15 +0000 (12:22 +0200)
committerXavier Morel <xmo@openerp.com>
Tue, 17 Jun 2014 10:22:15 +0000 (12:22 +0200)
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
openerp/addons/base/ir/ir_qweb.py

index f8d1a66..601d301 100644 (file)
             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);
index 5fb56a2..1209e45 100644 (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")