Odoo14后端按钮调⽤前端JS 1.视图页⾯
<form delete="0" duplicate="0" edit="0" create="0" js_class="local_sync_oss">
<header>
<button class="local_sync_oss" string="NAS同步照⽚到OSS"></button>
</header>
       </form>
js arguments2.JS
odoo.define('sps_service/static/src/local_sync_oss.js', function (require) {
"use strict";
var FormView = require('web.FormView');
var FormRenderer = require('web.FormRenderer');
var view_registry = require('web.view_registry');
var session = require('web.session');
var SpsServiceFormRenderer = d({
events: _.extend({}, FormRenderer.prototype.events, {
'click .local_sync_oss': 'local_sync_oss',
}),
init: function () {
this._super.apply(this, arguments);
},
// 这⾥可以在页⾯打开时提前获取⼀些需要的数据,和执⾏⼀些函数
start: function () {
this._super.apply(this, arguments);
let self = this
self._rpc({
model: 'respany',
method: 'search_read',
fields: ['flow_type', 'is_all_storage', 'locality_location'],
args: [[['id', '=', sessionpany_id]]],
}).then(res => {
// 获取存储类型
this.flow_type = res[0].flow_type
// 获取是否配置了允许外⽹访问
this.is_all_storage = res[0].is_all_storage
// 获取检测是否nas的url
this.locality_location = res[0].locality_location
})
this.service_order_id = 0
// 打开页⾯时执⾏⾃定义的函数
<_service_order_id()
},
get_service_order_id: function () {
console.log("6666666666");
},
local_sync_oss: function () {
console.log("点击按钮执⾏的函数");
}
})
var SpsServiceFormView = d({
jsLibs: [],
config: _.extend({}, fig, {
Renderer: SpsServiceFormRenderer,
}),
});
view_registry.add('local_sync_oss', SpsServiceFormView);
return {
Renderer: SpsServiceFormRenderer,    };
})

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。