I have a button which calls a function which then will open a wizard, now I am trying to implement a server action which will call the exact same method but it doesnt open the wizard. I want to display a wizard with error message if the server action code fail
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi,
Create a server action
<record id="model_product_template_inherit" model="ir.actions.server">
<field name="name">Wizard</field>
<field name="model_id" ref=product.model_product_template"/>
<field name="binding_view_types">form</field>
<field name="state">code</field>
<field name="code">action=recor.open_wizard()</field>
</record>
Then create a function on the corresponding model and return an action here mentioning the model and view_id.
def open_wizard(self):
return {
'name': 'Wizard',
'type': 'ir.actions.act_window',
'view_mode': 'form',
"view_type": "form",
'res_model': 'product.generation.wizard',
'target': 'new',
'view_id': self.env.ref
('product_generation.product_generation_wizard_form').id,
'context': {'active_id': self.id},
}
Regards
Hello Trong,
Find code in Comment.
I hope this will help you.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
Try to below code for the open wizard,
return {
"type": "ir.actions.act_window",
"res_model": "Model name",
"views": “form”,
"name": "Wizard name",
}
If you want to display an error message used to UserError as per your requirement
example: raise UserError(_('Your message.'))
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
May 25
|
200 | ||
|
0
May 25
|
224 | ||
|
1
May 25
|
577 | ||
|
4
May 25
|
1884 | ||
|
2
May 25
|
2038 |