Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Odoo cache and updating qweb templates

By
Eduardo BP
on 4/25/15, 9:26 PM 4,708 views

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...

Jérémy Kersten (jke)
on 4/26/15, 3:16 PM

Thanks for your answer jke. I have edited my post to write down the code from my controller.

Eduardo BP
on 4/27/15, 8:09 AM

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 ?

Jérémy Kersten (jke)
on 4/27/15, 8:37 AM

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 editable

on 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.
Eduardo BP
on 4/27/15, 11:10 AM

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 ?

Jérémy Kersten (jke)
on 4/27/15, 11:16 AM

- 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.
Eduardo BP
on 4/27/15, 11:56 AM

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.

Jérémy Kersten (jke)
on 4/27/15, 12:10 PM
-1
HateCamel
On 6/26/15, 3:33 PM

Did you solve this? I am having the same problem. I am adding some fields in account invoice report through my custom module and I have to create a new invoice to see my changes every time, event hough I restarted the server and updated the module.

You should go to Settings > Actions > Reports, find Invoice and disable the 'Reload from Attachment'. Hope that helps u :).

Juan Muñoz
on 9/7/15, 6:45 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 4/25/15, 9:26 PM
Seen: 4708 times
Last updated: 10/7/15, 4:55 AM