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?
Hope this will helps: https://learnopenerp.blogspot.com/2020/01/open-wizard-on-button-click-in-odoo.html