Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo template page doesn't update when xml changes

Tags:

openerp

Just started Odoo for a client, and I have a major problem with a template.

a simple template that has some divs and headers. I also have a record for it to show in the main menu.

Everything works when i first create it. However if it happens that i want to add or change some html, those changes don't show on the website page (even after I refresh/upgrade the theme). The website builder allows me to change the text and whatnot, but that's not what I need. I want to be able to change the html structure from the XML. But as soon as the page is created the first time... I'm not allowed to. The page will only display the page as first created.

Hope it's clear and thank you in advance for any help.

Joe

like image 812
j_o_e Avatar asked Mar 28 '17 23:03

j_o_e


2 Answers

Version: Odoo nightly 10.0-20170427

tl;dr

Each time you use the website builder (to add snippets, alter text,..) and save, data records in the Odoo database get modified (obviously - otherwise your changes wouldn't persist).

In the process, the value of the field "noupdate" in table "ir_model_data" is set from false to true for the record of your template. As long as "noupdate" is set to true the record for that template won't be altered by an upgrade action on your module.

To be able to change that, you will have to set "noupdate" back to false so the template in the database will be overwritten by the modified content of your xml during the upgrade process. Please check the warning at the bottom of my answer!

My similar problem

I came across a similar problem. Like you did, I created a simple module/template with a few html tags, added it to main_menu and installed the module. Everything worked as expected (menu link visible and all my content was shown).

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <!-- === Page template === -->
    <template name="tpl-imprint" id="website.imprint" page="True">
        <t t-call="website.layout">
            <div id="wrap">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12">
                            <h1>some Header</h1>
                            <p>some text</p>
                        </div>
                    </div>
                    <!-- === Snippets' area === -->
                    <div class="row">
                        <div class="oe_structure" />
                    </div>
                </div>
            </div>
        </t>
    </template>
    <!-- === Menu item === -->
    <record id="menu_imprint" model="website.menu">
        <field name="name">Imprint</field>
        <field name="url">/page/imprint</field>
        <field name="parent_id" ref="website.main_menu" />
        <field name="sequence" type="int">100</field>
        <field name="website_id" type="int">1</field>
    </record>
</odoo>

After that I modified my xml file a bit further, added some text etc, upgraded the module and again everything worked as expected. Then I experimented a bit with the website builder on the page I created myself, added some snippets and saved. Then I realized I had some typos in my xml so I went over to my editor, fixed them, upgraded the module and - not as expected - my view didn't get modified.

Since I'm fairly new to Odoo, didn't really dive into how Odoo works in the backend yet and I couldn't find anything good on google, I started to analyze what happens to the database during the upgrade process as well as by using the website builder. I found out that while just using upgrade to upload my changes, only the field "arch_db" of table "ir_ui_view" was altered for the related record. By using the website builder though, not only the template content was written into "ir_ui_view", but also the field "noupdate" for the related record in table "ir_model_data" was altered - it was set from false to true (There are probably more changes happening to the database, but those mentioned are the ones related to the problem).

How to make the upgrade process work again

To solve the upgrade problem, I simply changed the value of "noupdate" back to true and the upgrade process worked again. (You will have to do that every time you use the website builder with one of your custom templates - at least if you want to make changes to the template via your xml again).

Backup your database before altering it manually! (I've tested/used those sql lines with my database but sill no warranty ;))

Lookup the model_data_id of the template in "ir_ui_view"

select
    model_data_id
from
    ir_ui_view
where
    name = '<the name of your template - in my case tpl-imprint>';

Use that ID to find/update the related record in table "ir_ui_data"

update
    ir_model_data
set
    noupdate = true
where
    id = <the ID you got with the first query>

Done! Try upgrading your module. Your changes to the xml should be stored in the database now.


You could also alter the value in one step

update
    ir_model_data
set
    noupdate = false
where
    id in(
        select
            model_data_id
        from
            ir_ui_view
        where
            name = '<the name of your template - in my case tpl-imprint>'
    );

!!!! WARNING !!!!

All changes you made with the website builder will be lost during the upgrade process if you set "noupdate" to false. If you want to keep them you have to copy paste your modifications to your template in your xml! To do so, go to Customize/HTML Editor on the page you want to get content from and copy paste the parts you want to keep to your xml.

like image 196
coreuter Avatar answered Sep 28 '22 08:09

coreuter


Delete your template from the front end then update your module and check it up.

like image 28
sfx Avatar answered Sep 28 '22 08:09

sfx