Odoo Help


Why discard button does not work on my custom form?

Juan Formoso
on 10/27/14, 5:23 AM 2,362 views

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?




| 6 8 7
Bangalore, India
On 10/27/14, 6:13 AM

Hi for Discard button in xml you should pass special="cancel" class="oe_link" instead of type="object"

or  you can change the return attribute 'type': 'ir.actions.act_window_close'

Where I can change the code of the discard button of my form? Because I did not create it, it was generated automatically. If I change my button, and put special="cancel" and class="oe_link" instead of type="object", it does not open the form. What did you mean?

Juan Formoso
on 10/27/14, 6:23 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 10/27/14, 5:23 AM
Seen: 2362 times
Last updated: 3/16/15, 8:10 AM