I made a form to create an object from the table res.partner.link.category (model created by me too). This is the XML code:
<button name="create_rplc" type="object" string="Link / Unlink to a category"/>
And this is the Python code:
def create_rplc(self, cr, uid, ids, context=None):
if context is None:
context = {}
data_obj = self.pool.get('ir.model.data')
data_id = data_obj._get_id(cr, uid, 'res_partner_extended', 'res_partner_link_category_create_form_view')
view_id = False
if data_id:
view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
return {
'name': 'Creation',
'view_type': 'form',
'view_mode': 'form',
'views': [(view_id, 'form'),],
'res_model': 'res.partner.link.category',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'new',
'flags': {'form': {'action_buttons': True}},
}
It works fine, the form is opened and I can insert new records. The buttons Save and Discard are automatically generated. Save works well, but DIscard does nothing. I have to close the popup clicking on the X at the top right corner. Why Discard does not work? I thought that may be it is because something related to the property target (in the return of the function) or the XML code, type="object", but I do not have any idea.
Anyone can help me, please?