【问题标题】:Odoo V13 Custom fields in product menu don't show up产品菜单中的 Odoo V13 自定义字段不显示
【发布时间】:2020-04-18 14:38:11
【问题描述】:

我正在尝试向产品菜单添加一个简单的自定义字段,但它没有出现。

我对产品模型的修改在“技术>模型”菜单中可见,并且我的视图在视图列表中加载良好,没有错误或警告。

models/product.py

from odoo import fields, models

class Product(models.Model) :
    _inherit = 'product.product'
    test = fields.Boolean('Material')

models/init.py

# -*- coding: utf-8 -*-

from . import models
from . import material
from . import machine
from . import product

查看/product.xml

<?xml version="1.0"?>
<odoo>
    <record id="view_cbd_product" model="ir.ui.view">
        <field name="name">cbd.product</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.product_normal_form_view"/>
        <field name="arch" type="xml">
            <field name="sale_ok" position="after">
                <field name="test"/>
            </field>
        </field>
    </record>
</odoo>

清单.py

    'data': [
        'views/product.xml'
    ],

感谢您的帮助

【问题讨论】:

    标签: python xml field product odoo-13


    【解决方案1】:
    1. 在开发者模式下按错误
    2. 点击编辑查看表单
    3. 检查继承的视图选项卡以查看您的视图是否存在。

    【讨论】:

    • 确实我继承了错误的视图(好的是product.product_template_only_form_view)。我也将模型中的继承从“product.product”更改为“product.template”,但现在我有了错误“taxes_id 字段不存在”。我签入 product.template 模型并且我的字段在其中。当我手动将“taxes_id”字段添加到我的继承模型时,我不再收到该字段的错误.
    • 编辑:我删除了数据库并且按字段正在工作,感谢您的帮助!
    猜你喜欢
    • 2020-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    • 2019-04-24
    • 2021-04-28
    • 2017-06-24
    • 2019-01-09
    相关资源
    最近更新 更多