Hi,
I'm following the "Building a Website" tutorial from the developers official documentation, but I'm having a problem to see the changes made in the template (xml file) on the web page.
I have a model like this:
class Teachers(models.Model):
_name = 'academy.teachers'
name = fields.Char()
biography = fields.Html()
My original template was as follows:
<openerp>
<data>
<template id="index">
<t t-call="website.layout">
<t t-set="title">Academy</t>
<div class="oe_structure">
<div class="container">
<t t-foreach="teachers" t-as="teacher">
<p><a t-attf-href="/academy/{{ slug(teacher) }}">
<t t-esc="teacher.name"/></a>
</p>
</t>
</div>
</div>
</t>
</template>
<template id="biography">
<t t-call="website.layout">
<t t-set="title">Academy</t>
<div class="oe_structure">
<div class="container">
<h3><t t-esc="person.name"/></h3>
<div><t t-esc="person.biography"/></div>
</div>
</div>
</t>
</template>
</data>
</openerp>
Then, I change this template to be able to edit the person's name on the webpage.
<openerp>
<data>
<template id="index">
<t t-call="website.layout">
<t t-set="title">Academy</t>
<div class="oe_structure">
<div class="container">
<t t-foreach="teachers" t-as="teacher">
<p><a t-attf-href="/academy/{{ slug(teacher) }}">
<t t-esc="teacher.name"/></a>
</p>
</t>
</div>
</div>
</t>
</template>
<template id="biography">
<t t-call="website.layout">
<t t-set="title">Academy</t>
<div class="oe_structure">
<div class="container">
<h3 t-field="person.name"/>
<div t-field="person.biography"/>
</div>
</div>
</t>
</template>
</data>
</openerp>
I'm sending a person variable from the controller. person is a record from Teachers model.
The source code from my controller is as follows:
# -*- coding: utf-8 -*-
from openerp import http
class Academy(http.Controller):
@http.route('/academy/academy/', auth='public', website=True)
def index(self, **kw):
teachers = http.request.env['academy.teachers']
return http.request.render('academy.index', {
'teachers': teachers.search([])
})
@http.route('/academy/<model("academy.teachers"):teacher>', auth='public', website=True)
def teachers(self, teacher):
return http.request.render('academy.biography', {
'person': teacher
})
And here is the source code from my Teacher model:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class Teachers(models.Model):
_name = 'academy.teachers'
name = fields.Char()
biography = fields.Html()
I run the following command to start Odoo server updating my academy module:
./odoo.py --addons-path addons,/opt/odoo/custom-addons -d test -u academy
In the top navigation bar, if I click on the 'Customize-->HTML Editor menu', I can see the template 'biography' hadn't been updated. It still contains the original content of the templates.xml file with <h3><t t-esc="person.name"/></h3> instead
<h3 t-field="person.name"></h3>.
I think that it is due to something related to Odoo cache.
I cleared all Google Chrome cache, restart de Odoo server and updgrade my module, but it didn't work.
The only temporary solution is uninstall and install the module again, but I don't want to do this every time.
Any solution please?.
Could you provide some piece of code from your controller ? It's normal that template are not updated. You are updating the record sent from controller... not the template...
Thanks for your answer jke. I have edited my post to write down the code from my controller.
I don't have your template for index... but for controller academy/teacher... If you do : http://127.0.0.1/academy/1 (where 1 is the id from one of your teacher), if you edit it, the change should be done in the database for this teacher. Which Odoo version are you using ? V8 ?
I'm using Odoo version 8. But I think that I didn't explain clearly my problem in my original question. I have edited it to clarify. My problem is that I had a previous template to show the name of a teacher:
Then, I changed this template to have an editableon the webpage over the name of the teacher:
But somehow, the template didn't update and it still was containing instead . I think the problem is due to Odoo cache, but I'm not sure. I had to uninstall and install the module again to the template was updated.When you update a template, you need to restart your server with the option -u to update it. It's not a problem with cache, because when your restart your server, you clear always the cache ! (but according your question, you do it...) Maybe you have a data update="False" in your template ? Can you check that the module i well updated (no warning at startup WARNING ecom openerp.modules.loading: invalid module names, ignored: academy) If you do and update manually via the backend (setting, module , find your apps, update)... does it works ?
- I don't have a data update="False" in my template. - No warning at startup. - When I had the problem, a manually update of the module didn't work. I have tried to recreate the original problem. First, I uninstalled the module, then I changed my template.xml file to content the original code (without editable fields on the webpage). After this, I installed the module again and of course, the
tag containing the teacher's name wasn't editable. Everything fine for now. Again, I changed the template to contain an editable tag (
) and I restarted the Odoo server with the command ./odoo.py --addons-path addons,/opt/odoo/custom-addons -d test -u academy After this, the template was updated, but I promise that when I updated my template for the first time, the changes on the template.xml file weren't taken into account. I don't know what happened the first time, but I can't recreate the problem again. Thank for your help Jérémy.Good news ! The only thing that I can see is that template was marked as non updatable because you have edited it from the website front end. When it's the case, you can uncheck the non updatable field from the ir_model_dala (in backend) or do a -i (and not -u) to force the overwritte... Good continuation with Odoo.