mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
update common
This commit is contained in:
@@ -4,4 +4,5 @@ from . import res_config_settings
|
||||
from . import ir_ui_view
|
||||
from . import base_language_install
|
||||
from . import ir_module_module
|
||||
from . import web_environment_ribbon_backend
|
||||
# from . import ir_ui_menu
|
||||
|
||||
@@ -32,6 +32,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
app_account_title = fields.Char('My Odoo.com Account Title')
|
||||
app_account_url = fields.Char('My Odoo.com Account Url')
|
||||
app_enterprise_url = fields.Char('Customize Module Url(eg. Enterprise)')
|
||||
app_ribbon_name = fields.Char('Show Demo Ribbon')
|
||||
|
||||
@api.model
|
||||
def get_values(self):
|
||||
@@ -57,6 +58,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
app_account_title = ir_config.get_param('app_account_title', default='My Online Account')
|
||||
app_account_url = ir_config.get_param('app_account_url', default='https://www.sunpop.cn/my-account/')
|
||||
app_enterprise_url = ir_config.get_param('app_enterprise_url', default='https://www.sunpop.cn')
|
||||
app_ribbon_name = ir_config.get_param('app_ribbon_name', default='*Sunpop.cn')
|
||||
res.update(
|
||||
app_system_name=app_system_name,
|
||||
app_show_lang=app_show_lang,
|
||||
@@ -74,7 +76,8 @@ class ResConfigSettings(models.TransientModel):
|
||||
app_support_url=app_support_url,
|
||||
app_account_title=app_account_title,
|
||||
app_account_url=app_account_url,
|
||||
app_enterprise_url=app_enterprise_url
|
||||
app_enterprise_url=app_enterprise_url,
|
||||
app_ribbon_name=app_ribbon_name
|
||||
)
|
||||
return res
|
||||
|
||||
@@ -100,6 +103,7 @@ class ResConfigSettings(models.TransientModel):
|
||||
ir_config.set_param("app_account_title", self.app_account_title or "My Online Account")
|
||||
ir_config.set_param("app_account_url", self.app_account_url or "https://www.sunpop.cn/my-account/")
|
||||
ir_config.set_param("app_enterprise_url", self.app_enterprise_url or "https://www.sunpop.cn")
|
||||
ir_config.set_param("app_ribbon_name", self.app_ribbon_name or "*Sunpop.cn")
|
||||
|
||||
def set_module_url(self):
|
||||
sql = "UPDATE ir_module_module SET website = '%s' WHERE license like '%s' and website <> ''" % (self.app_enterprise_url, 'OEEL%')
|
||||
|
||||
36
app_odoo_customize/models/web_environment_ribbon_backend.py
Normal file
36
app_odoo_customize/models/web_environment_ribbon_backend.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class WebEnvironmentRibbonBackend(models.AbstractModel):
|
||||
|
||||
_name = "web.environment.ribbon.backend"
|
||||
_description = "Web Environment Ribbon Backend"
|
||||
|
||||
@api.model
|
||||
def _prepare_ribbon_format_vals(self):
|
||||
return {"db_name": self.env.cr.dbname}
|
||||
|
||||
@api.model
|
||||
def _prepare_ribbon_name(self):
|
||||
name_tmpl = self.env["ir.config_parameter"].sudo().get_param("app_ribbon_name") or False
|
||||
vals = self._prepare_ribbon_format_vals()
|
||||
return name_tmpl and name_tmpl.format(**vals) or name_tmpl
|
||||
|
||||
@api.model
|
||||
def get_environment_ribbon(self):
|
||||
"""
|
||||
This method returns the ribbon data from ir config parameters
|
||||
:return: dictionary
|
||||
"""
|
||||
ir_config_model = self.env["ir.config_parameter"]
|
||||
name = self._prepare_ribbon_name()
|
||||
return {
|
||||
"name": name,
|
||||
"color": ir_config_model.sudo().get_param("app_ribbon_color"),
|
||||
"background_color": ir_config_model.sudo().get_param(
|
||||
"app_ribbon_background_color"
|
||||
),
|
||||
}
|
||||
Reference in New Issue
Block a user