diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index a6487c38a51..b06aa2a4a90 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -193,14 +193,18 @@ class AssetsBundle(object): return response @func.lazy_property - def last_modified(self): + def last_modified_combined(self): """Returns last modified date of linked files""" + # WebAsset are recreate here when a better solution would be to use self.stylesheets and self.javascripts + # We currently have no garanty that they are present since it will depends on js and css parameters + # last_modified is actually only usefull for the checksum and checksum should be extension specific since + # they are differents bundles. This will be a future work. + + # changing the logic from max date to combined date to fix bundle invalidation issues. assets = [WebAsset(self, url=f['url'], filename=f['filename'], inline=f['content']) for f in self.files if f['atype'] in ['text/sass', "text/scss", "text/less", "text/css", "text/javascript", "text/xml"]] - return max(itertools.chain( - (asset.last_modified for asset in assets), - )) + return ','.join(str(asset.last_modified) for asset in assets) @func.lazy_property def version(self): @@ -210,9 +214,9 @@ class AssetsBundle(object): def checksum(self): """ Not really a full checksum. - We compute a SHA512/256 on the rendered bundle + max linked files last_modified date + We compute a SHA512/256 on the rendered bundle + combined linked files last_modified date """ - check = u"%s%s" % (json.dumps(self.files, sort_keys=True), self.last_modified) + check = u"%s%s" % (json.dumps(self.files, sort_keys=True), self.last_modified_combined) return hashlib.sha512(check.encode('utf-8')).hexdigest()[:64] def _get_asset_template_url(self): diff --git a/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py b/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py index 9a5df4e8b6f..cb7bacabbff 100644 --- a/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py +++ b/odoo/addons/test_assetsbundle/tests/test_assetsbundle.py @@ -204,7 +204,7 @@ class TestJavascriptAssetsBundle(FileTouchable): """ bundle0 = self._get_asset(self.jsbundle_name) bundle0.js() - last_modified0 = bundle0.last_modified + last_modified0 = bundle0.last_modified_combined version0 = bundle0.version path = get_resource_path('test_assetsbundle', 'static', 'src', 'js', 'test_jsfile1.js') @@ -212,7 +212,7 @@ class TestJavascriptAssetsBundle(FileTouchable): with self._touch(path): bundle1.js() - last_modified1 = bundle1.last_modified + last_modified1 = bundle1.last_modified_combined version1 = bundle1.version self.assertNotEqual(last_modified0, last_modified1, "the creation date of the ir.attachment should change because the bundle has changed.") @@ -486,13 +486,13 @@ class TestJavascriptAssetsBundle(FileTouchable): # Assets access for en_US language ltr_bundle0 = self._get_asset(self.cssbundle_name) ltr_bundle0.css() - ltr_last_modified0 = ltr_bundle0.last_modified + ltr_last_modified0 = ltr_bundle0.last_modified_combined ltr_version0 = ltr_bundle0.version # Assets access for ar_SY language rtl_bundle0 = self._get_asset(self.cssbundle_name, env=self.env(context={'lang': 'ar_SY'})) rtl_bundle0.css() - rtl_last_modified0 = rtl_bundle0.last_modified + rtl_last_modified0 = rtl_bundle0.last_modified_combined rtl_version0 = rtl_bundle0.version # Touch test_cssfile1.css @@ -502,7 +502,7 @@ class TestJavascriptAssetsBundle(FileTouchable): with self._touch(path): ltr_bundle1.css() - ltr_last_modified1 = ltr_bundle1.last_modified + ltr_last_modified1 = ltr_bundle1.last_modified_combined ltr_version1 = ltr_bundle1.version ltr_ira1 = self._any_ira_for_bundle('min.css') self.assertNotEqual(ltr_last_modified0, ltr_last_modified1) @@ -511,7 +511,7 @@ class TestJavascriptAssetsBundle(FileTouchable): rtl_bundle1 = self._get_asset(self.cssbundle_name, env=self.env(context={'lang': 'ar_SY'})) rtl_bundle1.css() - rtl_last_modified1 = rtl_bundle1.last_modified + rtl_last_modified1 = rtl_bundle1.last_modified_combined rtl_version1 = rtl_bundle1.version rtl_ira1 = self._any_ira_for_bundle('min.css', lang='ar_SY') self.assertNotEqual(rtl_last_modified0, rtl_last_modified1)