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
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.
Delete your template from the front end then update your module and check it up.
This is a major problem we are facing now. If I change the template by overriding the original website template My localhost is updated with new content and in production and live server it is not getting updated. I mainly made changes in website.layout template.
I also Found a solution, but that is not an efficient and practical way. For that I followed the steps below:
Activate Developer mode
Go to settings --> User Interface --> Views.
Search the template in the view and delete the proper ones and installed My custom module again.
But I can't say this is an efficient method and sometimes the record will arise error if we try to delete a template with relation.
when changes done in view or template in odoo you need to update module so that the changes reflect in view.
so try to update your module from apps or update from terminal
login into your database and run following command in terminal and reload page from browser.
For odoo 8,9
python openerp-server -u your_module_name
For odoo 10
python odoo-bin -u your_module_name
I had the same problem after trying to add some translation (to the i18 folder).
And my template didn't have any noupdate field. (neither in database or odoo frontend).
So my solution was to update the module with the terminal and -i instead of the regular -u. It seems forcing the overriding.
like :
python odoo-bin -i module_name
Related
When I navigate to a form using vue-router by adding a link with a <router-link> element, the form does not work. When I hit submit I get a 404 response.
However, if I navigate to it using an <a> tag (triggering a page reload) then it works perfectly.
I suspect that this has to do with the page rendering as a SPA and for some reason not loading an important part of the form for Netlify unless the form page is reloaded? Why is this happening and is there an elegant solution to the problem? I could just replace all links to forms with tags but I'm sure that there is a better solution, I just don't understand the problem well enough to find it.
For context, I am using Nuxt. The forms are recognized by Netlify on the backend and can accept submission with the tag link so that is not the problem.
Since you're using Nuxt, you probably should go SSG/full static with target: 'static' (hostable on Netlify-like platforms) or with target: 'server' (hostable on Heroku-like platforms) but at any point, you should have ssr: true (default value). When you do have this, the biggest part is done.
In Nuxt, you should use <nuxt-link> rather than <router-link>, it works exactly the same (takes the same params etc) but it's more specific to Nuxt and SSR/SSG compatible while <router-link> is not. More details here: https://nuxtjs.org/docs/2.x/features/nuxt-components#the-nuxtlink-component
So, with all of this it should already work great. If it's not, I will gladly help you spot the issue if you have a github repo.
An alternative solution can be to use some form without any SSR dependency like Formspree: https://formspree.io/ (works fine with any SPA)
It works great, really simple. But I'd rather invite you to make a proper SSR form since you're using Nuxt.
PS: use <a> tags only for external links aka the ones which do not start with your domain name, nothing else. A follow of this kind of link is like a hard refresh and should be avoided at all costs.
EDIT: how to deploy by cleaning the cache.
EDIT on how to achieve a working form:
<template>
<div>
<form
netlify
action="/"
method="POST"
name="Contact"
>
<input type="hidden" name="form-name" value="Contact" />
<!-- ... -->
</form>
</div>
</template>
As told in the docs:
[...] inject a hidden input named form-name [...] and the hidden form-name input’s value matches the name attribute of form
Working fine. Could add a honeypot to it to make it even more secure!
I am actually building a SPA with foalts.org.
I have placed my script.js inside the public folder. Unfortunately, this doesn't allow me to use typescript for my vue-js. Maybe someone has an idea for this, cause actually the public folder got served from foalTS framework. But this is actually not the main topic.
The maintopic is, that i want to list several divs with
<div class="row-position" v-for="order in orders" :key="order.latestPrice">
<div id="myAMchart></div>
</div>
Now I would like to be able to place an amChart (https://www.amcharts.com/) for each div. And I want that these charts follow the value of order.latestPrice. But I actually have no idea how to set up this with amCharts and vue.js
Im open to any ideas.
I was able to update one single chart but with a fixed id of the div.
I don't know how to connect the many different (dynamicaly generated) charts to the order.latestPrice field.
Thanks!
I'm using django-autocomplete-light with django 1.8.
I want to be able to copy the selected contents from one autocomplete field into another which requires overriding javascript code.
I tried duplicating the html content inside the autocomplete tool into another one in the browser debugger which looked good but when I click the save button in the admin page, it ignores my copied value.
Any ideas?
It works if you use an empty form for #form_template as such:
<div class = 'table' id="form_template" style="display:none">
{{ formset.empty_form }}
</div>
<div class = 'table'>
<table>
<!-- don't use #form_template in your actual form -->
From github issue
I have come to a road block in my search to the answer to using custom fields in templates.
I have tried adding
%%SNIPPET_ProductCustomFields%%
in the ProductDescription.html but nothing shows.
Is there ANY documentation about this?
Can this snippet be used in certain places only? if so which ones?
What needs to be in place for this to display in the products description?
Any help, tips or pointers would be great.
The CustomFields Snippet, %%SNIPPET_ProductCustomFields%%, can only be used if being referenced through its own Panel.
By default, the Panel that calls this snippet is named %%Panel.ProductOtherDetails%%
You can also create your own custom Panels by uploading them to the Panels folder via WebDav.
For example, if you created a template file called CustomFieldsPanel.html, you would upload it to the /dav/template/Panels folder, and reference it in your theme by %%Panel.CustomFieldsPanel%%
To answer your question though, you can do one of the following to display Custom Fields in the Product Description:
Insert it into ProductDescription.html via its default Panel - %%Panel.ProductOtherDetails%% - modifying it by editing the template file ProductOtherDetails.html
Create your own custom panel, include the Snippet within that same custom panel, and insert it into ProductDescription.html by the custom panel's name. An example of that file might look like so:
<!--
* /dav/template/Panels/MyCustomFieldsPanel.html
* %%Panel.MyCustomFieldsPanel%%
-->
<div id="MyCustomFieldsPanel">
<h1> Custom Fields Below </h1>
%%SNIPPET_ProductCustomFields%%
</div>
Hope this helps :-)
For whatever reason, whenever I build my project, any changes I've made to a view that are not html do not get displayed. Instead it pulls all the info from the partial view (which in our application doesn't get updated when I make a change in the view). So every time I build my project, the application serves me the partial view and I have to go into each view that I made changes in and make some sort of html change in order for the changes I made prior to the build display. Eventually, this functionality will change, but right now my boss doesn't want to mess with it just yet. I've tried disabling cache in chrome's dom (f12) as well as downloading an extension to force the page to not display any chached versions of pages but that doesn't seem to help. What else can I do until we get the partial views removed properly?
UPDATE:
I kinda goofed on the title. Whats happening is the generated files are what are being served to me from my localhost rather than any changes I made to a view (html or otherwise), if I made those changes prior to a build.
so in the view I'd have this:
<body>
<div>Hello World!</div
<div><h2>Sample Text</h2></div>
</body>
<script>
$(document).ready(function () {
//Some Javascript code
});
Which is the way the page was originally created by someone else. They also manually made a partial generated file and that file doesn't rre-generate when I make changes to the view.
So if I made these changes:
<body>
<div>Hello World again!</div
<div><h2>Sample Text</h2></div>
</body>
<script>
$(document).ready(function () {
//Some Javascript code
});
and then built the project, it would not serve me these changes, it would grab the generated file (which didn't get updated with my changes) and serve that to me unless AFTER I do the build, I go into that specific view and make an HTML Change (for some reason making a change with Javascript doesn't help). Then I can see my changes. AND it will stay that way until I do another build at which point, everything reverts back to the partial generated views until I make an HTML change in the view.
Deleting the Generated files is the only way I can see to fix the problem I just wasn't sure if it would break the application and it doesn't.