Skip to content

Commit

Permalink
[IMP] add url_for hook to bundle urls
Browse files Browse the repository at this point in the history
  • Loading branch information
amigrave committed Sep 16, 2014
1 parent 954f20c commit 7bc7757
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions openerp/addons/base/ir/ir_qweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ def __init__(self, xmlid, debug=False, cr=None, uid=None, context=None, registry

context = self.context.copy()
context['inherit_branding'] = False
context['rendering_bundle'] = True
self.html = self.registry['ir.ui.view'].render(self.cr, self.uid, xmlid, context=context)
self.parse()

Expand Down Expand Up @@ -1086,10 +1087,13 @@ def to_html(self, sep=None, css=True, js=True, debug=False):
for jscript in self.javascripts:
response.append(jscript.to_html())
else:
url_for = self.context.get('url_for', lambda url: url)
if css and self.stylesheets:
response.append('<link href="/web/css/%s/%s" rel="stylesheet"/>' % (self.xmlid, self.version))
href = '/web/css/%s/%s' % (self.xmlid, self.version)
response.append('<link href="%s" rel="stylesheet"/>' % url_for(href))
if js:
response.append('<script type="text/javascript" src="/web/js/%s/%s"></script>' % (self.xmlid, self.version))
src = '/web/js/%s/%s' % (self.xmlid, self.version)
response.append('<script type="text/javascript" src="%s"></script>' % url_for(src))
response.extend(self.remains)
return sep + sep.join(response)

Expand Down

0 comments on commit 7bc7757

Please sign in to comment.