diff --git a/backend_theme_infinito_plus/__manifest__.py b/backend_theme_infinito_plus/__manifest__.py index cd821e50a..3020cff53 100644 --- a/backend_theme_infinito_plus/__manifest__.py +++ b/backend_theme_infinito_plus/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'Backend Theme Infinito Plus', - 'version': "15.0.1.0.0", + 'version': "15.0.1.0.1", 'category': 'Extra Tools', 'summary': 'The Backend Theme Infinito Is A Dynamic And Ultimate Theme' 'For Your Odoo V15. This Theme Will Give You A New Experience ' diff --git a/backend_theme_infinito_plus/controllers/backend_theme_infinito_plus.py b/backend_theme_infinito_plus/controllers/backend_theme_infinito_plus.py index 7d96cb13c..aaac2f33b 100644 --- a/backend_theme_infinito_plus/controllers/backend_theme_infinito_plus.py +++ b/backend_theme_infinito_plus/controllers/backend_theme_infinito_plus.py @@ -26,6 +26,7 @@ from odoo import http from odoo.http import request from odoo.addons.backend_theme_infinito.controllers.main import ThemeStudio from odoo.addons.backend_theme_infinito.controllers.main import minify_css +from odoo.modules.module import get_module_resource class ThemeStudioPlus(ThemeStudio): @@ -35,9 +36,7 @@ class ThemeStudioPlus(ThemeStudio): def save_styles_plus(self, new_style): """Create Dynamic Styles css file for chat box layout""" changed_styles = json.loads(new_style) - working_dir = os.path.dirname(os.path.realpath(__file__)) - working_dir = working_dir.replace('/controllers', '') - file_path = working_dir + '/static/src/css/chatter.css' + file_path = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'css', 'chatter.css') style_file = open(file_path, 'a') style_file.truncate(0) if os.stat(file_path).st_size == 0: @@ -56,9 +55,7 @@ class ThemeStudioPlus(ThemeStudio): """ create the Dynamic css file for animation""" animated = json.loads(style) saved_style = animated[0] - working_dir = os.path.dirname(os.path.realpath(__file__)) - file_path = working_dir.replace('/controllers', - '/static/src/scss/animation.scss') + file_path = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'scss', 'animation.scss') read_file = open(file_path, 'r') css = read_file.read() write_file = open(file_path, 'w') @@ -105,13 +102,10 @@ class ThemeStudioPlus(ThemeStudio): @http.route(['/theme_studio_plus/reset_to_default_style'], type="json") def reset_to_default_style(self): """rest to default styles""" - working_dir = os.path.dirname(os.path.realpath(__file__)) - style_file_path = working_dir.replace('controllers', - 'static/src/css/font.css') - animation_file_path = working_dir.replace('controllers', - 'static/src/scss/animation.scss') - chat_file_path = working_dir.replace('controllers', - 'static/src/css/chatter.css') + style_file_path = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'css', 'font.css') + animation_file_path = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'scss', + 'animation.scss') + chat_file_path = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'css', 'chatter.css') style_file = open(style_file_path, 'w') style_file.write('') animation_read_file = open(animation_file_path, 'r') diff --git a/backend_theme_infinito_plus/doc/RELEASE_NOTES.md b/backend_theme_infinito_plus/doc/RELEASE_NOTES.md index 48d56c2ff..d062128b5 100644 --- a/backend_theme_infinito_plus/doc/RELEASE_NOTES.md +++ b/backend_theme_infinito_plus/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 15.0.1.0.0 #### ADD - Initial Commit for Infinito Backend Theme Plus + +#### 05.07.2025 +#### Version 15.0.1.0.1 +#### ADD +- Updated how module resources are fetched in the backend. diff --git a/backend_theme_infinito_plus/models/infinito_google_font.py b/backend_theme_infinito_plus/models/infinito_google_font.py index f2fa53b54..c2fa2d9e4 100644 --- a/backend_theme_infinito_plus/models/infinito_google_font.py +++ b/backend_theme_infinito_plus/models/infinito_google_font.py @@ -19,10 +19,10 @@ # If not, see . # ############################################################################# -import os import requests -from odoo import api, fields, models, _ +from odoo import api, fields, models +from odoo.modules.module import get_module_resource class GoogleFont(models.Model): @@ -64,9 +64,7 @@ class GoogleFont(models.Model): def set_css(self): """open the file write the style in to the css file""" - working_dir = os.path.dirname(os.path.realpath(__file__)) - working_dir = working_dir.replace('/models', - '/static/src/css/font.css') + working_dir = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'css', 'font.css') # open the file in write mode with open(working_dir, 'w') as file: style = f""" @@ -84,9 +82,7 @@ class GoogleFont(models.Model): @staticmethod def remove_fonts(): """remove the style when changing the font""" - working_dir = os.path.dirname(os.path.realpath(__file__)) - working_dir = working_dir.replace('/models', - '/static/src/css/font.css') + working_dir = get_module_resource('backend_theme_infinito_plus', 'static', 'src', 'css', 'font.css') open(working_dir, "r") with open(working_dir, 'w') as file: file.write('')