我想在POS屏幕上添加舍入功能,使用XML添加舍入文本。
我用于 qweb XML的代码如下
ro_template.xml
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="OrderWidget">
<t t-jquery="div[class='subentry']" t-operation="after">
<div class='actual_value' style="font-size:19px">Payable: <span class="value">0.00€</span></div>
<div class='rounding' style="font-size:16px">Taxes: <span class="value">0.00€</span></div>
</t>
</t>
</templates>
但是javascript无法添加四舍五入量
我的JavaScript代码如下
rounding.js
odoo.define('rounding.rounding', function (require) {
"use strict";
var core = require('web.core');
var screens = require('point_of_sale.screens');
var _t = core._t;
screens.OrderWidget = screens.OrderWidget.include({
update_summary: function() {
console.debug('--------------- START');
screens.OrderWidget.prototype.update_summary.call(this);
var order = this.pos.get_order();
if (!order.get_orderlines().length) {
return;
}
var subtotal = order ? total - order.get_total_without_tax() : 0;
this.el.querySelector('.summary .total .subentry .subtotal')
.textContent = this.format_currency(subtotal);
console.debug('--------------- END');
}
});
});
和添加javascript的XML如下
round_templates.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/round/static/src/js/rounding.js"></script>
</xpath>
</template>
</odoo>
任何人都可以帮忙吗?