【发布时间】:2020-07-11 11:53:14
【问题描述】:
我在“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>
“名称”字段出现,但由于某种原因“分支”字段没有出现,我无法找出原因。
【问题讨论】:
-
从浏览器的开发者模式检查,执行“console.dir(posmodel);”我可以清楚地看到该字段已添加并具有值
标签: odoo customization pos odoo-13