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.

1

Open View from Button

By
Patrik
on 3/27/15, 9:45 AM 1,686 views

Hi

I'm stuck, I tried every example I found, but somehow it still doesn't work. I'd like to open a new view from a button in the statusbar. Here are my two approaches.

I'm extending sale_order, file: sale_order.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record
model="ir.ui.view" id="view_sale_order_form_wizard">
<field
name="name">sale.order.form</field>
<field
name="model">sale.order</field>
<field
name="inherit_id" ref="sale.view_order_form" />
<field
name="arch" type="xml">
<header>
<button
type='action' name='%(custom_wizard_ext_view)d' string="Button A" />
<button
type='object' name='open_wizard' string="Button B" />
</header>
</field>
</record>
</data>
</openerp>


The two buttons appear, so everything fine to this point.


Button A:
Should open a new, customize view (just a dummy view at this moment). This view will create products later.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record
id="custom_wizard_ext_view" model="ir.ui.view">
<field
name="name">product.product.form</field>
<field
name="model">product.product</field>
<field
name="type">form</field>
<field
name="arch" type="xml">
<data>
<field
name="name" colspan="4" />
<group
col="4" colspan="4">
<button
name="save" string="Save" type="object" colspan="1" />

</group>
</data>
</field>
</record>
</data>
</openerp>

Shouldn't %(custom_wizard_ext_view)d open this view?


Button B:

Call of a function which is in my file sale_order.py:

from openerp import models, fields


class sale_order(models.Model):
_inherit = 'sale.order'

def open_wizard(self, cr, uid, ids, context=None):
return {
'type': 'ir.actions.act_window',
'res_model': 'product.product',
'view_type': 'form',
'view_mode': 'form',
'res_id': 'custom_wizard_ext_view',
'target': 'new',
}

When I click "Button B" I get this error:

TypeError: open_wizard() takes exactly 1 argument (5 given) 


Which one is the right approach to open a view from a button in the status bar?









1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 3/27/15, 10:52 AM

In new api try this:

@api.multi 
def open_wizard(self):
....

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

1 follower(s)

Stats

Asked: 3/27/15, 9:45 AM
Seen: 1686 times
Last updated: 3/27/15, 6:13 PM