gpt4 book ai didi

javascript - 如何在 Odoo 9 中执行 JS 文件中的函数?

转载 作者:行者123 更新时间:2023-11-28 06:02:25 25 4
gpt4 key购买 nike

我已成功扩展了 Point_of_Sale 模块中的“PosTicket”模板,并在现有模板中包含了几个字段。我还编写了类似于 screen.js (render_reciept) 中的函数来获取新添加字段的值。我面临的问题是,我无法调用该函数。如何执行该函数?

这是扩展的模板:

<?xml version="1.0" encoding="UTF-8"?>
<template>
<t t-extend="PosTicket">
<t t-jquery=".receipt-orderlines"
t-operation="before">
customer name:<t t-esc="customer_name"/>
<br />
customer street:<t t-esc="street"/>
<br />
customer city:<t t-esc="city"/>
<br />
</t>
</t>
</template>

这是 js 文件:

odoo.define('custom_module.print_cust_details_pos_bill', function (require) {
"use strict";
var core = require('web.core');
var screens = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var QWeb = core.qweb;

var BillScreenWidget = screens.ReceiptScreenWidget.extend({
template: 'BillScreenWidget',
show: function(){
this._super();
var self = this;
this.render_receipt();
},

render_receipt: function(){
console.log("Render Reciept funtion called");
this._super();
//RKD-Start
var customer = this.pos.get_order().get_client();
var street = '';
var city ='';
var customer_name='';
if (customer != undefined)
{
customer_name = customer.name;
street = customer.street;
city=customer.city;
}

this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{
widget:this,
order: order,
receipt: order.export_for_printing(),
orderlines: order.get_orderlines(),
paymentlines: order.get_paymentlines(),
customer_name:customer_name,
customer_street:street,
city:city,
}));

//RKD-End
}

});
gui.define_screen({name:'receipt', widget: custom_module.BillScreenWidget});
});

最佳答案

您是否尝试过将其调用到start中?每当小部件被注入(inject)到 DOM 中时就会调用它,并且看起来像是执行此操作的地方。检查official docs中的“使用小部件” .

关于javascript - 如何在 Odoo 9 中执行 JS 文件中的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37179524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com