OdooTech notes

Wizard from button in odoo

odoo personalizzazioni

Creating and opening a wizard from button in odoo

Define wizard in .py:

class ProductWizard(models.TransientModel):
   _name = 'product.wizard'

   date_from = fields.Date(string='From')
   date_to = fields.Date(string='To')

   def test_report(self):
       context = dict(self._context or {})
       raise UserError(_("TEST REPORT"))

Define action e view in .xml:

<record id="action_open_wizard" model="ir.actions.act_window">
   <field name="name">View Product Wizard</field>
   <field name="res_model">product.wizard</field>
   <field name="view_type">form</field>
   <field name="view_mode">tree,form</field>
   <field name="view_id" ref="view_test_report_wizard"/>
   <field name="target">new</field>

<record id="view_test_report_wizard" model="ir.ui.view">
   <field name="name">Product Wizard</field>
   <field name="model">product.wizard</field>
   <field name="arch" type="xml">
   <form string="Choose The Details">
         <field name="date_from" />
         <field name="date_to"/>
   <button name="test_report" string="Print" type="object" class="oe_highlight" />
   <button string="Cancel" class="oe_link" special="cancel"/>

Call for action in XML:

Comment here