Ajuda

0

How to use my own template?

Avatar
Jon Wong

I create a new theme module, extended 'web.main.Home' controller, and tried to render my own template:

<template id="theme.login" name="my_login">


I get error: Template 'theme.login' not found.


Is there something I must do to register my template with Odoo?


@Axel

What about this tutorial (http://odoo-80.readthedocs.org/en/latest/guides/themes.html) that uses id of "website.hello"?

Avatar
Descartar
2 Respostas
1
Avatar
Axel Mendoza
Melhor Resposta

Your template need to be like this:

<template id="theme_login" name="my_login" inherit_id="web.main.Home">

remove the '.' in the template id


Avatar
Descartar
0
Avatar
Jon Wong
Melhor Resposta

@Axel

What about this tutorial (http://odoo-80.readthedocs.org/en/latest/guides/themes.html) that uses id of "website.hello"?

4 Comentários
Avatar
Descartar
Avatar
Axel Mendoza
-

when you put a '.' in an template or record Odoo will split the string to get the first part as the module and the second part as the id that you want to use for your template/record to change that template/record and that id need to exist registered in ir.model.data to be found and the id 'website.hello' is something created for that example, it's not part of Odoo as neither 'theme.login', if this is a template defined in a module named 'theme' with the name 'login' then you need to be sure that the module it's installed and put a depend with that module, otherwise change the id of your template accordingly

Avatar
Jon Wong
-

@Axel: I tried what you suggested, id of "theme_login", name of "my_login", inherit_id of "web.main.Home". The new error is "Invalid template id: 'theme_login'". The reason I don't want to inherit "web.login" is because I want to completely override that template.

Avatar
Jon Wong
-

@Axel: Sorry, my mistake. The error is actually: "ParseError: "External ID not found in the system: web.main.Home" while parsing".

Avatar
Jon Wong
-

@Axel: What works is this: id of "web.theme_login", no inherit_id attribute. Can you explain to me why that works and why your suggestion didn't work? I just hope to understand Odoo more. I'll mark your explanation as the answer to this question. Thanks!