本文整理汇总了Python中openerp.addons.base.ir.ir_qweb.AssetsBundle.js方法的典型用法代码示例。如果您正苦于以下问题:Python AssetsBundle.js方法的具体用法?Python AssetsBundle.js怎么用?Python AssetsBundle.js使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openerp.addons.base.ir.ir_qweb.AssetsBundle
的用法示例。
在下文中一共展示了AssetsBundle.js方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_date_invalidation
# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import js [as 别名]
def test_03_date_invalidation(self):
""" Checks that a bundle is invalidated when one of its assets' modification date is changed.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle0.js()
last_modified0 = bundle0.last_modified
version0 = bundle0.version
path = get_resource_path('test_assetsbundle', 'static', 'src', 'js', 'test_jsfile1.js')
utime(path, None) # touch
bundle1 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle1.js()
last_modified1 = bundle1.last_modified
version1 = bundle1.version
self.assertNotEquals(last_modified0, last_modified1)
self.assertNotEquals(version0, version1)
# check if the previous attachment is correctly cleaned
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
示例2: test_04_content_invalidation
# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import js [as 别名]
def test_04_content_invalidation(self):
""" Checks that a bundle is invalidated when its content is modified by adding a file to
source.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle0.js()
html0 = bundle0.html
version0 = bundle0.version
self.assertEquals(len(self._any_ira_for_bundle("js")), 1)
view_arch = """
<data>
<xpath expr="." position="inside">
<script type="text/javascript" src="/test_assetsbundle/static/src/js/test_jsfile4.js"/>
</xpath>
</data>
"""
bundle_id = self.browse_ref(self.jsbundle_xmlid).id
newid = self.registry["ir.ui.view"].create(
self.cr,
self.uid,
{"name": "test bundle inheritance", "type": "qweb", "arch": view_arch, "inherit_id": bundle_id},
)
bundle1 = AssetsBundle(
self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={"check_view_ids": [newid]}, registry=self.registry
)
bundle1.js()
html1 = bundle1.html
version1 = bundle1.version
self.assertNotEquals(html0, html1)
self.assertNotEquals(version0, version1)
# check if the previous attachment are correctly cleaned
self.assertEquals(len(self._any_ira_for_bundle("js")), 1)
示例3: test_02_access
# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import js [as 别名]
def test_02_access(self):
""" Checks that the bundle's cache is working, i.e. that the bundle creates only one
ir.attachment record when rendered multiple times.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle0.js()
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
version0 = bundle0.version
ira0 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('js')[0])
date0 = ira0.create_date
bundle1 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle1.js()
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
version1 = bundle1.version
ira1 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('js')[0])
date1 = ira1.create_date
self.assertEquals(version0, version1)
self.assertEquals(date0, date1)
示例4: test_04_content_invalidation
# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import js [as 别名]
def test_04_content_invalidation(self):
""" Checks that a bundle is invalidated when its content is modified by adding a file to
source.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, env=self.env)
bundle0.js()
html0 = bundle0.html
version0 = bundle0.version
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
view_arch = """
<data>
<xpath expr="." position="inside">
<script type="text/javascript" src="/test_assetsbundle/static/src/js/test_jsfile4.js"/>
</xpath>
</data>
"""
bundle_id = self.browse_ref(self.jsbundle_xmlid).id
newid = self.registry['ir.ui.view'].create(self.cr, self.uid, {
'name': 'test bundle inheritance',
'type': 'qweb',
'arch': view_arch,
'inherit_id': bundle_id,
})
bundle1 = AssetsBundle(self.jsbundle_xmlid, env=self.env(context={'check_view_ids': [newid]}))
bundle1.js()
html1 = bundle1.html
version1 = bundle1.version
self.assertNotEquals(html0, html1)
self.assertNotEquals(version0, version1)
# check if the previous attachment are correctly cleaned
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
示例5: TestJavascriptAssetsBundle
# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import js [as 别名]
class TestJavascriptAssetsBundle(TransactionCase):
def setUp(self):
super(TestJavascriptAssetsBundle, self).setUp()
self.jsbundle_xmlid = 'test_assetsbundle.bundle1'
self.cssbundle_xmlid = 'test_assetsbundle.bundle2'
def _any_ira_for_bundle(self, type):
""" Returns all ir.attachments associated to a bundle, regardless of the verion.
"""
bundle = self.jsbundle_xmlid if type == 'js' else self.cssbundle_xmlid
return self.registry['ir.attachment'].search(self.cr, self.uid,[
('url', '=like', '/web/content/%-%/{0}%.{1}'.format(bundle, type))
])
def test_01_generation(self):
""" Checks that a bundle creates an ir.attachment record when its `js` method is called
for the first time.
"""
self.bundle = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
# there shouldn't be any attachment associated to this bundle
self.assertEquals(len(self._any_ira_for_bundle('js')), 0)
self.assertEquals(len(self.bundle.get_attachments('js')), 0)
# trigger the first generation and, thus, the first save in database
self.bundle.js()
# there should be one attachment associated to this bundle
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
self.assertEquals(len(self.bundle.get_attachments('js')), 1)
def test_02_access(self):
""" Checks that the bundle's cache is working, i.e. that the bundle creates only one
ir.attachment record when rendered multiple times.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle0.js()
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
version0 = bundle0.version
ira0 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('js')[0])
date0 = ira0.create_date
bundle1 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle1.js()
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
version1 = bundle1.version
ira1 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('js')[0])
date1 = ira1.create_date
self.assertEquals(version0, version1)
self.assertEquals(date0, date1)
def test_03_date_invalidation(self):
""" Checks that a bundle is invalidated when one of its assets' modification date is changed.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle0.js()
last_modified0 = bundle0.last_modified
version0 = bundle0.version
path = get_resource_path('test_assetsbundle', 'static', 'src', 'js', 'test_jsfile1.js')
utime(path, None) # touch
bundle1 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle1.js()
last_modified1 = bundle1.last_modified
version1 = bundle1.version
self.assertNotEquals(last_modified0, last_modified1)
self.assertNotEquals(version0, version1)
# check if the previous attachment is correctly cleaned
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
def test_04_content_invalidation(self):
""" Checks that a bundle is invalidated when its content is modified by adding a file to
source.
"""
bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
bundle0.js()
html0 = bundle0.html
version0 = bundle0.version
self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
view_arch = """
<data>
<xpath expr="." position="inside">
<script type="text/javascript" src="/test_assetsbundle/static/src/js/test_jsfile4.js"/>
</xpath>
</data>
"""
bundle_id = self.browse_ref(self.jsbundle_xmlid).id
newid = self.registry['ir.ui.view'].create(self.cr, self.uid, {
'name': 'test bundle inheritance',
'type': 'qweb',
'arch': view_arch,
#.........这里部分代码省略.........