You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo 10产品表单添加字段问题:字段已创建但界面不显示

Troubleshooting: Custom Field Not Showing on Product Template Form

Hey there! Let's figure out why your my_field isn't showing up on the product template form even though it exists in the database. I've dealt with this exact issue a few times, so here are the most common fixes to walk through:

1. Double-check your view inheritance syntax

First, make sure your XML view is targeting the right parent view and using correct XPath logic:

  • Confirm your inherit_id references the exact external ID: product.product_template_form_view (spelling and case matter here—Odoo is picky about external IDs!).
  • Try using an explicit XPath expression instead of the shortcut syntax, sometimes this resolves targeting issues:
    <xpath expr="//field[@name='standard_price']" position="after">
        <field name="my_field"/>
    </xpath>
    
  • Ensure your view is set up as an extension view (this is default, but double-check you didn't accidentally set mode to something else).

2. Verify field permissions and attributes

Your field might exist in the database, but be hidden due to permissions or default attributes:

  • Check if you added a groups restriction to the field in your model. If you did, make sure your current user is part of that group. For example:
    my_field = fields.Float(string="My Field", groups="base.group_user")
    
  • Look for readonly=True or invisible=True in your field's model definition. If either is set, you'll need to explicitly override them in the view (e.g., <field name="my_field" invisible="False"/>).

3. Ensure your module and view are properly loaded

Sometimes updates don't stick, or views fail to validate:

  • Go to Apps > Find your module > Upgrade to re-apply your module's changes. Watch for any error messages during the upgrade—they'll often point directly to the issue.
  • Check if your view is valid: Head to Settings > Technical > User Interface > Views, search for your custom view, and confirm its status is Valid. If it's Invalid, click into it to see the error (usually something like "XPath couldn't find the target element").

4. Check for conflicting views

Other modules might be overriding the same section of the product form:

  • In the Views menu, search for product.product_template_form_view and look at the Inherited Views tab. If another view is loaded after yours, it might be overwriting your changes.
  • Give your view a higher priority value (e.g., priority="100") so it applies later and overrides conflicting changes. Here's how to add it:
    <record id="custom_product_template_form" model="ir.ui.view">
        <field name="name">product.template.form.custom</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_form_view"/>
        <field name="priority">100</field> <!-- Higher = applies later -->
        <field name="arch" type="xml">
            <field name="standard_price" position="after">
                <field name="my_field"/>
            </field>
        </field>
    </record>
    

5. Clear browser cache or use incognito mode

Browsers love caching old versions of pages. Clear your cache, or open the product form in incognito/private browsing mode to rule out cached content blocking your new field.

6. Debug mode deep dive

Turn on debug mode (add ?debug=1 to your Odoo URL), then:

  • Open the product form and click Edit View: Form in the top-right corner.
  • Look for your my_field in the view source. If it's there but not visible, check for hidden groups or invisible attributes. If it's not there at all, your view inheritance isn't being applied correctly.

Start with these steps—9 times out of 10, one of them will fix the issue!

内容的提问来源于stack exchange,提问作者Cleber Goncalves

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:31:17