Override a default view by a custom module? - odoo

Is there a way to override openerp's default views, developing a module instead of doing it manually from Settings / Customization / User Interface / Views...?
We are using OpenERP and customizing a lot of default views (Project List, Invoice List, Invoice Search etc) adding and hiding fields from list and search filters / groups, we are doing it manually view by view from web client.
Is there a way to develop a module where I can write the xml for all the views I want to customize, and when I install that module all that views (and window actions as well) will be updated?

You can use View Inheritance to customize any view using XML files.
Using inheritance, you can add, remove and replace elements to any view. You can also define new complete views to replace the default instead of inheritance. Just create a new module with the XML files that customizes or replaces the current views and load that module. The module folder should contain only __init__.py, __openerp__.py and the XML files.
Here is a simple example to remove the EAN13 field from the product view.
__init__.py empty file
__openerp__.py:
{
"name" : "View Customization Test",
"version" : "1.0",
"category" : "Generic Modules/Inventory Control",
'depends' : ['product',],
"update_xml" : ["product.xml",],
"installable": True,
"active": True
}
product.xml:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="ir.ui.view" id="view_product_form_custom">
<field name="name">product.form.inherit2</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<field name="ean13" position="replace" />
</field>
</record>
</data>
</openerp>

Of course there is. You can create your custom module and install it. See the basics in the official docs. The Technical Memento is also something you should have at hand.
This makes it a lot easier to develop and test in a development environment, and afterwards copy and install in the production environment.

Certainly it is possible (and it is good idea to do it.)
First read the fundamentals of the view and view inheritance
then simply create a folder under your addons
add a __init__.py [python module descriptor]
Add __openerp__.py [OpenERP Module Descriptor]
Create an xml file and inheirt the required view with the XML Identifier of the existing view and register your view.xml in __openerp__.py.
And update your databse with your new module.

Related

TypeError: list.fields[order.name] is undefined

We are currently trying to upgrade to odoo 11 (from 10). We could fix most issues of our custom modules while installing them in new odoo 11 but now i get the following runtime error:
TypeError: list.fields[order.name] is undefined
http://10.15.0.183:8069/web/content/975-35dc0a2/web.assets_backend.js:1293
Traceback:
compareRecords#http://10.15.0.183:8069/web/content/975-35dc0a2/web.assets_backend.js:1293:190
Any ideas whats wrong? Any possibility to debug this or to find out where this exactly happens? the Traceback does not tell anything and in odoo-server log there is nothing.
we have different custom moduls extending articles,customers..
Try to unpack js files to get a better js error that will lead you exactly to where is located the issue, or at least a clear path to start debugging the JS issue in the browser. Try to reproduce the issue starting the page load from this URL
http://10.15.0.183:8069/web?debug=assets
you can also activate debugging mode from the Settings app or using a plugin for your browser:
chrome
Firefox
I know this question is old, but I had the same problem today.
I'm just sharing the fix in my case (Axel Mendoza "debug=assets" answer helped me to pinpoint the bug).
The problem was a mistake in a form view :
a <tree> element was used to render a many2many field, and the default_order attribute was referencing a field not used inside the <tree> definition.
Wrong XML :
<field name="my_many2many_field">
<tree default_order="my_field_0">
<field name="my_field_1"/>
<field name="my_field_2"/>
</tree>
</field>
In my case the fix was to add the field referenced by the default_order attribute, as an invisible field, inside the <tree> definition.
Fixed XML :
<field name="my_many2many_field">
<tree default_order="my_field_0">
<field name="my_field_0" invisible="1"/>
<field name="my_field_1"/>
<field name="my_field_2"/>
</tree>
</field>

Odoo template page doesn't update when xml changes

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

How do I totally remove the "follow" functionality on Odoo/OpenERP?

I'm talking about the follow button under users. Can this be done with Access control without modifying the views?
Hi Alexander Suraphel,
In your form view of our object at the bottom you will find following syntax :
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
in this :
here message_follower_ids add the follow feature so you can remove that line, and that will remove that feature from that object on that view.
Thanks

joomla 3 custom module class name

Running Joomla 3.1.5
I created a very simple module and I can't find anywhere in the module options where to add a class name. This was easy in earlier versions of Joomla; there was a "Menu Class Suffix" field under "ADVANCED OPTIONS."
How do I add a class name to my custom module? Thanks for the answers.
In your manifest (mod_yourmodule.xml) add the following field inside the respective fieldset
<field name="moduleclass_sfx"
type="text"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"/>
Hope it helps.

Displaying images in Popup of ArcGIS Flexviewer

I have created a sample flex application using the ArcGIS Flex viewer and trying to access some images from web(wiki).
I have successfully configured the pop-up XML files such that it displays the images. However when I click on the feature, it is not showing the image.
I was thinking if this could be because of the fact that these images are larger to include within the pop-up window.
I have tried the following workarounds of using different tags in the Pop-up config xml.
workaround:1
<description><![CDATA[<img src="{LINK_NEW}"/>{LINK_NEW}.<br>a. ]]>
</description>
workaround:2
<medias>
<media chartfields="" type="image" imagesource="{LINK_NEW}" imagelink="{LINK_NEW}" />
</medias>
The second seems to get me near to the resolution but not able to see the images in the pop-up window.
The question here is, I wanted to know a way to resize the original image with the help of xml tags and also if possible I wanted to increase the size of the pop-up window as well as to reduce the size of image that fits the pop-up window.
My configuration file is like the below:
<?xml version="1.0" ?>
<configuration>
<title>{NAME}</title>
<medias>
<media chartfields="" type="image" imagesource="{LINK_NEW}" imagelink="{LINK_NEW}" />
</medias>
<fields>
<field name="NAME" alias="NAME" visible="true"/>
<field name="LOCID" alias="LOCID" visible="true"/>
<field name="STATE" alias="STATE" visible="true"/>
<field name="ACAIS" alias="ACAIS" visible="true"/>
<field name="LINK_NEW" alias="LINK_NEW" visible="false"/>
</fields>
<showattachments>true</showattachments>
</configuration>
Thanks in advance.
I just figured out that we cannot access larger images in the pop-up window, which might be an enhancement that needs to be done with the pop-up configuration.
And also figured out that accessing larger images is possible through FLEX API by using image control in the pop-up configuration. Below are the few links that might be helpful.
Image Control:
http://livedocs.adobe.com/flex/3/html/help.html?content=controls_16.html
PopUpRendererSkin:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/skins/PopUpRendererSkin.html