Hello,
I have a custom module that has a new item in the "More" contextual dropdown menu. When the item is clicked, it calls an action saved to the ir.action.server. The action executes python code like it's supposed to. The python code creates a new record on the sale.order table and is supposed to open the sale.order form with the newly created record. I have a return statement at the end of the python code which is supposed to open the sale.order form, but for some reason it isn't. I don't understand why, because the same return statement works on other function calls except this one. Can anyone help me open the sale.order form after my function has created a new record on the sale.order model?
Here is the code that adds the line to the "More" contextual dropdown:
<record model="ir.values" id="test_more_item">
<field name="name">New More Item</field>
<field name="model" eval="'sale.licenses'" />
<field name="key" >action</field>
<field name="key2">client_action_multi</field>
<field name="value" eval="'ir.actions.server,%d'%sale_license_more_item_action" />
<field name="object" eval="True" />
</record>
This is the action the the "More" item calls. its from the ir.action.server
<record id="sale_license_more_item_action" model="ir.actions.server">
<field name="name">Renew Licenses</field>
<field name="type">ir.actions.server</field>
<field name="res_model">sale.order</field>
<field name="model_id" >283</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="state">code</field>
<field name="code">self.renew_license(cr, uid, context.get('active_ids', []), context=context)</field>
</record>
This is the function that is called from the server action
def renew_license(self, cr, uid, ids, context=None):
...(code that creates new sale.order record)
return {
'name': 'Sale Order Form',
'view_type': 'form',
'view_mode': 'form',
'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name','=','sale.order.form')])[0],
'res_model': 'sale.order',
'res_id': new_order_id,
'type': 'ir.actions.act_window',
}
Normally the return statement would open the sale.order form, but in this case it isn't. Does anyone know what I am doing wrong with this?