微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

POS 中模型“res.partner”上的无效字段“Odoo 13

如何解决POS 中模型“res.partner”上的无效字段“Odoo 13

我在 res.partner 中添加一个新字段,然后在 POS 的客户视图中;但是在编辑或创建客户时;保存时出错。 这是我的代码,将字段从 xml 保存到数据库缺少什么? 谢谢。

odoo.define('My_module.My_module',function (require) {
"use strict";

var models = require('point_of_sale.models');
models.load_fields('res.partner',['my_field']);


<templates id="point_of_sale.template" xml:space="preserve">
    <t t-extend="ClientDetails">
        <t t-jquery=".client-details-right" t-operation="append">
            <div class="client-detail">
                <span class="label">My Field</span>
                <t t-if='partner.my_field'>
                     <span class='detail client'><t t-esc='partner.my_field' /></span>
                </t>
                        <t t-if='!partner.my_field'>
                            <span class='detail client empty'>N/A</span>
                 </t>
            </div>

        </t>
    </t>


    <t t-extend="ClientDetailsEdit">
        <t t-jquery=".client-details-right" t-operation="append">
            <div class="client-detail">
                <span class="label">My Field</span>
                       <input class='detail client' type="date" t-att-value='partner.my_field'></input>
            </div>
            </t>
    </t>

</templates>

解决方法

如果没有字段名,Odoo将无法写入值,您可以在日志中看到以下错误:

File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py",line 3395,in write
    field = self._fields[fname]
KeyError: ''

您需要将输入的名称设置为 my_field

示例:

<input class='detail client' name="my_field" type="date" t-att-value='partner.my_field'></input>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。