Odoo Help


For which reason can I add a value to view_ids of a window action?

Pascal Tremblay
on 2/12/16, 5:36 PM 1,742 views

Hello all,

In a window action, there is the field view_ids. This field is a one2many field. 

When I add this in the xml record, it doesn't work.

Should it work? 

        <record id="action_invoice_tree1_cf" model="ir.actions.act_window">
<field name="name">Sales invoices - CF action</field>
<field name="res_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field eval="False" name="view_id"/>
<field name="domain">[('type','=','out_invoice')]</field>
<field name="context">{'default_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale'}</field>
<field name="search_view_id" ref="account.view_account_invoice_filter" />
<field name="limit" type="int">500</field>
             <field name="view_ids" eval="[(4, 0, [ref('account.invoice_form')])]" />

ABsolutely none example in all odoo 8 files for this.

Pascal Tremblay
on 2/12/16, 5:38 PM
Priyesh Solanki
On 2/12/16, 6:00 PM

The views field on the ir.actions.act_window model is a non-stored computed field, without an inverse function. In other words it's read-only and is not even stored in the database. That's why when you create a new action with this field, it is not saved and just gets ignored.

The documentation is a little confusing (I also had a hard time orginaly figuring this out), but not technically wrong. This field is indeed a list of (view_id, view_type) pairs, you just can't change it directly when dealing with actions stored in database. It is generated automatically, based on view_id and view_ids fields.

You can however use the field directly with actions that are not stored in the database, but returned from the python code instead. Here's an example taken from the account_payment module:

return {
    'name': _('Entry Lines'),
    'context': context,
    'view_type': 'form',
    'view_mode': 'form',
    'res_model': 'payment.order.create',
    'views': [(resource_id,'form')],
    'type': 'ir.actions.act_window',
    'target': 'new',

Ouf! I'm not crazy! Thanks a lot

Pascal Tremblay
on 2/12/16, 7:30 PM

About This Community

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 2/12/16, 5:36 PM
Seen: 1742 times
Last updated: 7/4/16, 8:14 AM