[FIX] website: 'Display Editor Bar on Website' group stopped working at commit a2ef04...
authorChristophe Matthieu <chm@odoo.com>
Thu, 25 Sep 2014 13:32:25 +0000 (15:32 +0200)
committerOlivier Dony <odo@openerp.com>
Fri, 26 Sep 2014 14:50:34 +0000 (16:50 +0200)
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
addons/website/static/src/js/website.editor.js
addons/website/static/src/js/website.js
addons/website/views/website_backend_navbar.xml
openerp/addons/base/ir/ir_qweb.py

index da9de18..ebb1753 100644 (file)
@@ -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:
index ee6368e..82888c5 100644 (file)
 
             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);
             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 () {
index 76756c0..be99c8e 100644 (file)
                 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');
index d30e541..820248d 100644 (file)
@@ -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">
index c244fe2..d27d15b 100644 (file)
@@ -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))