Odoo Help

Welcome!

This community 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.

0

Why discard button does not work on my custom form?

By
Juan Formoso
on 10/27/14, 5:23 AM 1,418 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?

0

Maniganda

--Maniganda--
1038
| 5 7 7
Bangalore, India
--Maniganda--
Maniganda
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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