Files
odoo_source/addons/share/web/editors.py
T
Xavier Morel 804fa924cf [FIX] share: share wizard would not open in some cases due to view_id not being found in ir_act_window
Switch to using the action_id itself instead of reverse-matching action_id from view_id
* Not all ir_act_window have a view_id, for some we're supposed to go through ir_act_window_view
* Multiple ir_act_window (or ir_act_window_view) may have the same view_id, and we don't really have enough information to select the right one

Keep the old resolution via view_id for now, in case users update their web client and their addons out of sync

bzr revid: xmo@openerp.com-20110208123241-lj8v12ygz2a0jsgx
2011-02-08 13:32:41 +01:00

42 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
import openobject.templating
class ShareActionEditor(openobject.templating.TemplateEditor):
templates = ['/openerp/widgets/templates/sidebar.mako']
ADD_SHARE_SECTION = u'id="sidebar"'
def insert_share_link(self, output):
# Insert the link on the line right after the link to open the
# attachment form
share_opener_insertion = output.index(
'\n',
output.index(self.ADD_SHARE_SECTION)) + 1
return output[:share_opener_insertion] + \
'''<div id="share-wizard" class="sideheader-a"><h2>${_("Sharing")}</h2></div>
<ul class="clean-a">
<li>
<a id="sharing" href="#share">${_("Share")}</a>
</li>
</ul>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#sharing").click(function() {
jQuery(this).attr(
"href",
openobject.http.getURL('/share', {
context: jQuery("#_terp_context").val(),
domain: jQuery("#_terp_domain").val(),
view_id: jQuery("#_terp_view_id").val(),
action_id: jQuery("#_terp_action_id").val(),
search_domain: jQuery("#_terp_search_domain").val(),
}));
});
});
</script>
\n''' + \
output[share_opener_insertion:]
def edit(self, template, template_text):
return self.insert_share_link(
super(ShareActionEditor, self).edit(template, template_text))