Search code examples
python-2.7odooopenerp-8

How to override this buttons?


When I trying to add a new record for a One2many tree, I've got a new pop up from(like the image below), I've need validate every value added to the tree, for that, I used onchange methods but they don't work properly...I would like override the method called when I click over the 'Save & Close' button, I tried overriding the write method, but in this way I don't have so many control over the error message what I want show for every single record added. I'm sure the best way to do what I need is get the name for method called when I clicked over the Save & Close method(In other words what method send the values from popup from to the One2many tree?). Please please HELPPP ME! enter image description here

EDIT: Or how can I call a specific from(wizard) clicking on Add an item???


Solution

  • Call method on Button "Save & Close"

    Add Js in module and do like this.

    In js file:

    openerp.module_name = function(instance) {
    
    var QWeb = openerp.web.qweb;
        _t = instance.web._t;
    
    instance.web.FormView.include({
        load_form: function(data) {
            var self = this;
            this.$el.find('.oe_abstractformpopup-form-save').click(this.on_button_save);
            return self._super(data);
        },
        on_button_save: function() {
            this.dataset.index = null;
            this.do_show();
            console.log('Save & Close button method call...');
        },
    });
    };