admin管理员组文章数量:1336632
I want to change a function in js
file. How to do it? Is there any ways to override the function?
addons/web/static/src/js/views/form_mon.js
,
i want to change the function-get_search_result: function(search_val){}
dataset.name_search(search_val, self.build_domain(), 'ilike', 160).done(function(_data) {self._search_create_popup("search", _data);}
need to change the value 160
to something else
Thanks in advance
I want to change a function in js
file. How to do it? Is there any ways to override the function?
addons/web/static/src/js/views/form_mon.js
,
i want to change the function-get_search_result: function(search_val){}
dataset.name_search(search_val, self.build_domain(), 'ilike', 160).done(function(_data) {self._search_create_popup("search", _data);}
need to change the value 160
to something else
Thanks in advance
Share Improve this question edited May 5, 2018 at 9:22 Jignasha Royala 1,03011 silver badges27 bronze badges asked May 5, 2018 at 6:23 HVHHVH 2471 gold badge6 silver badges15 bronze badges 2- Just inherit base file in your custom module and then override function. You get reference from web modules only how to inherit file. You can get reference from form_relation_widget.js After that call your function without super. Now it is overridden. – Keval Mehta Commented May 5, 2018 at 8:51
-
I have some issues in POS, could you please help? my questions are here on StackOverflow:
1.
stackoverflow./questions/60280924/…,2.
stackoverflow./questions/60349247/… – GD- Ganesh Deshmukh Commented Feb 22, 2020 at 7:12
2 Answers
Reset to default 3There is a good answer/example on this question, which gives a pretty good overview. That example is actually a bit more in depth than necessary for a global JavaScript change.
If you identify the function you want to override, then it's mostly just a matter of mirroring core and making the override(s) you want. Here's an example overview of how to change the name_search
JavaScript behavior:
your_module/manifest.py
...
'data': [
...
'views/assets.xml',
...
],
...
your_module/views/assets.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="assets_backend" name="custom assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/your_module/static/src/js/custom.js"></script>
</xpath>
</template>
</data>
</odoo>
your_module/static/src/js/custom.js
odoo.define('your_module.custom_feature', function(require) {
"use strict";
Class = require('web.Class');
mixins = require('web.mixins');
var DataSet = Class.extend(mixins.PropertiesMixin, {
name_search: function (name, domain, operator, limit) {
/* Custom code to override/extend core */
},
});
return {
DataSet: DataSet,
};
});
You can do it like they did in google_calendar
:
odoo.define('youmodule.yourmodule', function (require) {
"use strict";
var CompletionFieldMixin = require('web.CompletionFieldMixin');
var _t = core._t;
var QWeb = core.qweb;
CompletionFieldMixin.include({
// You need to redefine the function here
});
本文标签: javascriptHow to inherit or override js file in odooStack Overflow
版权声明:本文标题:javascript - How to inherit or override js file in odoo? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742414096a2470373.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论