Hi everyone here,
How can I return an action window or wizard from def copy or def write method in odoo 10.
Thank you very much.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi everyone here,
How can I return an action window or wizard from def copy or def write method in odoo 10.
Thank you very much.
Thank you very much for your effort to reply. I appreciated it.
Hii,
In Odoo 10 , def copy() and def write() are not designed to return an action (like opening a wizard or form view), because:
BUT... There are workarounds depending on whyYou want to return an action:
from odoo import models, api class MyModel (models.Model): _name = 'my.model' @api.multi def copy_and_open_wizard ( self ): # Step 1: Duplicate the record new_record = self.copy() # Step 2: Return a wizard action return { 'name' : 'Open Wizard' , 'type' : 'ir.actions.act_window' , 'res_model' : 'my.wizard.model' , 'view_mode' : 'form' , 'view_type' : 'form' , 'target' : 'new' , 'context' : { 'default_related_id' : new_record. id # pre-fill field in wizard } }
<button name = "copy_and_open_wizard" type = "object" string = "Copy & Open Wizard" class = "btn-primary" />
from odoo import models, fields class MyWizard (models.TransientModel): _name = 'my.wizard.model' related_id = fields.Many2one( 'my.model' , string= 'Related Record' ) notes = fields.Text( 'Notes' )
i hope it is usefull
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Dec 24
|
940 | ||
|
2
Oct 24
|
1075 | ||
|
1
Aug 24
|
2180 | ||
|
2
Jul 24
|
1455 | ||
|
1
Jul 24
|
1039 |