So, I've created a few buttons in their own modules with their own functionality. They do get displayed on the main POS screen.
I need to change the functionality slightly - have these button displayed only when a new modal is opened - the buttons rendered inside the modal will have their initial click functionality
(i do not know any Python)
How do I inherit the buttons functionality in the new modal in order to have the click event do individual tasks according to each button initial definition ?
I tried to use the
click_me: function(){
button1.click ......
button2.click
}
but for some reason i cant make that happen
first of all add your js file following code :
odoo.define('Modulename.filename', 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//
}
this._super();
},
});
});
after this add your js file in xml :
<?xml version="1.0" encoding="utf-8"?> <odoo>
<template id="assets_backend" name="project assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/product_pack/static/src/js/product_pack.js"></script>
</xpath>
</template> </odoo>
ather that define your click event function in your py file
class SalePetOrder(models.Model):
_inherit = "xyz"
def java_script(self):
return {"hello": "world"}
after define your function in your xml :
<data>
<header>
<button name="java_script" string="Java Script" type="object" custom="click"/>
</header>
</data
and yes define your js file and xml file in your manifest /openerp file .
I hope it helps you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.