Odoo Help

0

How to customize the onclick Javascript action of an "Edit" button (Odoo 10)

By
Jan Schlenker
on 10/22/17, 9:21 AM 318 views

 I want to customize the onclick Javascript action for the form of the model stock.picking. What is the easiest way to do this

0
Manish Bohra
On 10/23/17, 12:43 AM

Hello Jan, 

Add code in your js file 

/**window.alert("Page is Reload");**/
odoo.define('Module.js file name', function (require) {
"use strict";
var form_widget = require('web.form_widgets');
var core = require('web.core');
var _t = core._t;
var QWeb = core.qweb;
form_widget.WidgetButton.include({
    on_click: function() {
         if(this.node.attrs.custom === "click"){
            //code //
         return;
         }
         this._super();
    },
});
});

and define into your xml file : 

<button name="java_script" string="Java Script" type="object" custom="click"/>

There java_script is my function name which one define in .py file.

I hope it's help you

Thanks 

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.

Register

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

1 follower(s)

Stats

Asked: 10/22/17, 9:21 AM
Seen: 318 times
Last updated: 10/23/17, 12:43 AM