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.

0

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

By
Pascal Tremblay
on 2/12/16, 5:36 PM 731 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')])]" />
 
</record>

ABsolutely none example in all odoo 8 files for this.

Pascal Tremblay
on 2/12/16, 5:38 PM
1
Priyesh
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

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: 2/12/16, 5:36 PM
Seen: 731 times
Last updated: 7/4/16, 8:14 AM