Reputation: 573
I have added a button on wizard "Change Standard Price(stock.change.standard.price)". It is accessible from Products-> Procurement Tab -> "- update" link.
As soon as I click on that button wizard get closed though I don't want to close it. It should be close when I click on "Apply" or "cancel".
Here is the code:
Button:
<button string="New Cost" name="get_price" type="object" class="oe_inline"/>
Method:
def get_price(self, cr, uid, ids, context=None):
cost_price = 100
return {'new_price': cost_price, 'nodestroy': True}
I am returning nodestroy too as I read it will for not destroying wizard.
Am I doing something wrong?
Thanx in advance.
Upvotes: 2
Views: 5199
Reputation: 61
(Odoo 9/10) The simplest thing to do is do avoid closing the wizard :
@api.multi
def null_action(self):
return {
"type": "set_scrollTop",
}
As the type is used to call any method on the class ActionManager (javascript)
It's better than "type": "ir.actions.do_nothing" which generate an exception (this attribute doesn't exist)
Upvotes: 0
Reputation: 2137
you should return the dictionary like this to reopen the wizard,
view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','your wizard')])
return {
'type': 'ir.actions.act_window',
'res_model': 'your wizard',
'name': _('Your wizard Heading'),
'res_id': ids[0],
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'target': 'new',
'nodestroy': True,
'context': context
}
Upvotes: 2
Reputation: 16733
Try to return dictionary like
return {
'name':_("wizard name"),
'view_mode': 'form',
'view_type': 'form',
'res_model': 'model', # your current model
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'context': {'default_fieldname': 'your value'}
}
This will reopen the wizard.if you want to reopen the wizard.
Upvotes: 0