我已经在'res.company'模型中添加了一个字段,我正尝试将它们添加到收据中,但是它们没有显示。我在下一个python文件中添加了字段:
# -*- coding: utf-8 -*-
from odoo import models, fields, api, exceptions
class MyModuleCompany(models.Model):
_inherit = 'res.company'
branch_code = fields.Integer(string='Branch code')
然后用下面的代码在POS公司模型中添加了字段:
odoo.define('my_module.company', function (require) {
"use strict";
var models = require('point_of_sale.models');
models.load_fields('res.company', [
'branch_code'
]);
});
最后,我尝试使它们显示在带有下一个xml代码的收据中:
<?xml version="1.0" encoding="UTF-8"?>
<template xml:space="preserve">
<t t-extend="OrderReceipt">
<t t-jquery=".pos-receipt-contact" t-operation="replace">
<div class="pos-receipt-contact">
<t t-if='receipt.company.name'>
<div><t t-esc='receipt.company.name' /></div>
</t>
<t t-if='receipt.company.branch_code'>
<div>Branch:<t t-esc='receipt.company.branch_code' /></div>
</t>
</div>
</t>
</t>
</template>
出现“名称”字段,但由于某种原因,“分支”字段没有出现,我找不到原因。