-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien DRECQ
committed
Nov 26, 2021
1 parent
2ad0256
commit bc358e6
Showing
5 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Smile Assets Version", | ||
"version": "0.1", | ||
"sequence": 100, | ||
"category": "Tools", | ||
"author": "Smile", | ||
"license": 'AGPL-3', | ||
"website": 'http://www.smile.fr', | ||
"description": """ | ||
This module replace checksum on files assets by checksum based on | ||
code_version of smile_upgrade when server.environment == prod | ||
""", | ||
"depends": [ | ||
'website', | ||
'smile_upgrade', | ||
], | ||
"data": [], | ||
'installable': True, | ||
'auto_install': True, | ||
'application': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import ir_qweb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.fr>) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
||
import hashlib | ||
import json | ||
|
||
from odoo import models, tools | ||
from odoo.addons.website.models.ir_qweb import AssetsBundleMultiWebsite | ||
|
||
|
||
class SmileAssetsVersionBundle(AssetsBundleMultiWebsite): | ||
|
||
@tools.func.lazy_property | ||
def checksum(self): | ||
def old_checksum(): | ||
check = u"%s%s" % (json.dumps(self.files, sort_keys=True), | ||
self.last_modified) | ||
return hashlib.sha1(check.encode('utf-8')).hexdigest() | ||
if tools.config.get('server.environment', False) in \ | ||
['preprod', 'prod']: | ||
code_version = \ | ||
self.env['ir.config_parameter'].sudo().get_param( | ||
'code.version') | ||
if code_version: | ||
return hashlib.sha1(code_version.encode('utf-8')).hexdigest() | ||
return old_checksum() | ||
|
||
|
||
class QWeb(models.AbstractModel): | ||
_inherit = 'ir.qweb' | ||
|
||
def get_asset_bundle(self, xmlid, files, remains=None, env=None): | ||
return SmileAssetsVersionBundle(xmlid, files, remains=remains, env=env) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.