Exemplo n.º 1
0
 def _bundle(self, should_create, should_unlink):
     self.counter.clear()
     files, remains = self.env['ir.qweb']._get_asset_content(self.lessbundle_xmlid, {})
     asset = AssetsBundle(self.lessbundle_xmlid, files, remains, env=self.env)
     asset.to_html(debug='assets')
     self.assertEquals(self.counter['create'], int(should_create))
     self.assertEquals(self.counter['unlink'], int(should_unlink))
Exemplo n.º 2
0
 def _get_asset(self):
     files, remains = self.env['ir.qweb']._get_asset_content(
         self.lessbundle_xmlid, {})
     return AssetsBundle(self.lessbundle_xmlid,
                         files,
                         remains,
                         env=self.env)
Exemplo n.º 3
0
    def livechat_lib(self, ext, **kwargs):
        # _get_asset return the bundle html code (script and link list) but we want to use the attachment content
        xmlid = 'im_livechat.external_lib'
        files, remains = request.env["ir.qweb"]._get_asset_content(xmlid, options=request.context)
        asset = AssetsBundle(xmlid, files, remains)

        mock_attachment = getattr(asset, ext)()
        if isinstance(mock_attachment, list):  # suppose that CSS asset will not required to be split in pages
            mock_attachment = mock_attachment[0]
        # can't use /web/content directly because we don't have attachment ids (attachments must be created)
        status, headers, content = binary_content(id=mock_attachment.id, unique=asset.checksum)
        content_base64 = base64.b64decode(content) if content else ''
        headers.append(('Content-Length', len(content_base64)))
        return request.make_response(content_base64, headers)
Exemplo n.º 4
0
 def _get_asset(self, xmlid, env=None):
     env = (env or self.env)
     files, remains = env['ir.qweb']._get_asset_content(xmlid, env.context)
     return AssetsBundle(xmlid, files, remains, env=env)