我试图在安装我的服装模块时更改odoo的徽标。意味着我将提供的任何标志将取代默认标志。所以我尝试重写,也控制器正在执行,但结果不显示。不会产生错误。下面的代码是我的控制器代码。如何通过odoo中的模块更改默认徽标9
main.py
class Extension(main.Binary):
@http.route([
'/demo_theme/extension/company_logo',
'/logo',
'/logo.png',
], type='http', auth="none", cors="*")
def company_logo(self, dbname=None, **kw):
imgname = 'logo'
imgext = '.png'
placeholder = functools.partial(get_resource_path, 'demo_theme', 'static', 'src', 'img')
uid = None
if request.session.db:
dbname = request.session.db
uid = request.session.uid
elif dbname is None:
dbname = db_monodb()
if not uid:
uid = openerp.SUPERUSER_ID
if not dbname:
response = http.send_file(placeholder(imgname + imgext))
else:
try:
# create an empty registry
registry = openerp.modules.registry.Registry(dbname)
with registry.cursor() as cr:
cr.execute("""SELECT c.logo_web, c.write_date
FROM res_users u
LEFT JOIN res_company c
ON c.id = u.company_id
WHERE u.id = %s
""", (uid,))
row = cr.fetchone()
if row and row[0]:
image_base64 = str(row[0]).decode('base64')
image_data = StringIO(image_base64)
imgext = '.' + (imghdr.what(None, h=image_base64) or 'png')
response = http.send_file(image_data, filename=imgname + imgext, mtime=row[1])
else:
response = http.send_file(placeholder('nologo.png'))
except Exception:
response = http.send_file(placeholder(imgname + imgext))
return response
,我把这个控制器我.xml文件
<img src='/demo_theme/extension/company_logo'/>
但是,图像不被替换。所以任何人有任何想法,请与我分享。
感谢
Thanx @Charif为您的回复,我只是按照上面的和默认的标志显示。但在登录页面中,徽标不播种。所以建议我如何解决这个问题。 – Debasish
尝试http://127.0.0.1:8069/logo并得到我的日志,也是控制器覆盖,当我在检查中更改路径,所以我可以得到的标志,但路径不覆盖。 不覆盖。我不知道,我做了什么? – Debasish
登录页面中的徽标来自Web模块中的模板,如果您擅长Qweb,则必须搜索它,以便覆盖它pyh Xpath表达式(如果不搜索)模板位于Web模块中: 这两个模板是由Qweb或直接编辑它们的设计并升级您的Web模块 – Cherif