diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py
index fd6199a4fd6..1928b644073 100644
--- a/addons/share/web/editors.py
+++ b/addons/share/web/editors.py
@@ -11,8 +11,13 @@ class ShareActionEditor(openobject.templating.TemplateEditor):
share_opener_insertion = output.index(
'\n',
output.index(self.ADD_SHARE_SECTION)) + 1
- return output[:share_opener_insertion] + \
- '''
+ return output[:share_opener_insertion] + '''
+ <%
+ if 'has_share' not in cp.session:
+ cp.session['has_share'] = rpc.RPCProxy('share.wizard').has_share()
+ %>
+ % if cp.session['has_share']:
+
-
${_("Share")}
@@ -33,8 +38,9 @@ class ShareActionEditor(openobject.templating.TemplateEditor):
});
});
- \n''' + \
- output[share_opener_insertion:]
+ \n
+ % endif
+''' + output[share_opener_insertion:]
def edit(self, template, template_text):
return self.insert_share_link(
diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py
index 48243c57dda..755e4777eca 100644
--- a/addons/share/wizard/share_wizard.py
+++ b/addons/share/wizard/share_wizard.py
@@ -50,6 +50,18 @@ class share_create(osv.osv_memory):
_name = 'share.wizard'
_description = 'Share Wizard'
+ def has_group(self, cr, uid, module, group_xml_id, context=None):
+ """Returns True if current user is a member of the group identified by the module, group_xml_id pair."""
+ # if the group was deleted or does not exist, we say NO (better safe than sorry)
+ try:
+ model, group_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, module, group_xml_id)
+ except ValueError:
+ return False
+ return group_id in self.pool.get('res.users').read(cr, uid, uid, ['groups_id'], context=context)['groups_id']
+
+ def has_share(self, cr, uid, context=None):
+ return self.has_group(cr, uid, module='share', group_xml_id='group_share_user', context=context)
+
_columns = {
'action_id': fields.many2one('ir.actions.act_window', 'Action to share', required=True,
help="The action that opens the screen containing the data you wish to share."),