1 # -*- coding: utf-8 -*-
2 import openobject.templating
4 class ShareActionEditor(openobject.templating.TemplateEditor):
5 templates = ['/openerp/widgets/templates/sidebar.mako']
6 ADD_SHARE_SECTION = u'id="sidebar"'
8 def insert_share_link(self, output):
9 # Insert the link on the line right after the link to open the
11 share_opener_insertion = output.index(
13 output.index(self.ADD_SHARE_SECTION)) + 1
14 return output[:share_opener_insertion] + '''
16 if 'has_share' not in cp.session:
17 cp.session['has_share'] = rpc.RPCProxy('share.wizard').has_share()
19 % if cp.session['has_share']:
20 <div id="share-wizard" class="sideheader-a"><h2>${_("Sharing")}</h2></div>
23 <a id="sharing" href="#share">${_("Share")}</a>
26 <script type="text/javascript">
27 jQuery(document).ready(function() {
28 jQuery("#sharing").click(function() {
31 openobject.http.getURL('/share', {
32 context: jQuery("#_terp_context").val(),
33 domain: jQuery("#_terp_domain").val(),
34 view_id: jQuery("#_terp_view_id").val(),
35 action_id: jQuery("#_terp_action_id").val(),
36 search_domain: jQuery("#_terp_search_domain").val(),
43 ''' + output[share_opener_insertion:]
45 def edit(self, template, template_text):
46 return self.insert_share_link(
47 super(ShareActionEditor, self).edit(template, template_text))