forked from Smile-SA/odoo_addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPL] #1102404: Merge smile_assets_version to V15
- Loading branch information
lahcen akkhrraz
committed
Jan 6, 2022
1 parent
53312de
commit 4ef75e9
Showing
6 changed files
with
133 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,65 @@ | ||
====================== | ||
Assets version | ||
====================== | ||
|
||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-Smile_SA%2Fodoo_addons-lightgray.png?logo=github | ||
:target: https://github.com/Smile-SA/odoo_addons/tree/13.0/smile_anonymization | ||
:alt: Smile-SA/odoo_addons | ||
|
||
|badge2| |badge3| | ||
|
||
|
||
This module consists of modifying the hash generated in the assets link (ex: /web/content/240939-0489698/1/web.assets_common.0.css). | ||
Natively the hash is based on the file date in the filesystem. To prevent the assets from being regenerated all the time, | ||
the hash is no longer based on the file date but on the version of smile_upgrade (ir_config_parameter: code.version). | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Requirements | ||
============ | ||
|
||
This module depends on smile_upgrade module. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/Smile-SA/odoo_addons/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/Smile-SA/odoo_addons/issues/new?body=module:%smile_anonymization%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Smile SA | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Julien DRECQ | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the Smile SA. | ||
|
||
Since 1991 Smile has been a pioneer of technology and also the European expert in open source solutions. | ||
|
||
.. image:: https://avatars0.githubusercontent.com/u/572339?s=200&v=4 | ||
:alt: Smile SA | ||
:target: https://www.smile.eu | ||
|
||
This module is part of the `odoo-addons <https://github.com/Smile-SA/odoo_addons>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
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) 2021 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) 2021 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) 2021 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,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2021 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, env=None): | ||
return SmileAssetsVersionBundle(xmlid, files, env=env) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.