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

Odoo 10扩展res_partner视图:新增标签页后表单无法打开

Troubleshooting: Res_partner form won't load after adding a new tab via view inheritance

Hey there, I've run into this exact frustrating scenario before—Odoo module installs fine, but the form just dies on load with zero backend logs. Let's break down the likely issues and fixes for your code:

1. Fix the field name in your attrs (this is probably the root cause)

Looking at your attrs attribute: you're using is_customer, but the standard res.partner model uses the customer boolean field, not is_customer. Odoo's frontend will choke silently when it tries to evaluate an undefined field, which explains the form failing to load without backend errors.

Also, you had an extra trailing comma in the domain ([('is_customer','=',False),])—remove that too, it can cause parsing issues.

2. Make your XPath more precise

Using just //page[@name='accounting'] might accidentally match a page tag elsewhere in the view hierarchy (unlikely, but possible in customized environments). Lock it down to the notebook tab by updating the XPath to:

<xpath expr="//notebook/page[@name='accounting']" position="after">

3. Add a higher priority to your inherited view

If other modules are also modifying the partner form's notebook, your view might be loading before them, meaning the accounting page doesn't exist yet when your inheritance runs. Boost your view's priority to ensure it loads later:

<field name="priority">100</field>

Add this line right after the model field in your view record—higher numbers mean the view applies later, overriding or extending earlier changes.

4. Clear caches (don't skip this!)

Odoo loves to hold onto old view definitions in cache. Do all of these:

  • Restart your Odoo server
  • Open the form page in your browser with a hard refresh (Ctrl+Shift+R on Windows/Linux, Cmd+Shift+R on Mac)
  • If you're in developer mode, go to Settings > Technical > User Interface > Views, find your Partner Extended View, and click the "Refresh" button

5. Check browser console for frontend errors

Backend logs might be quiet, but the browser's dev tools usually tell the story. Press F12 to open dev tools, go to the "Console" tab, and reload the form. You'll likely see a JS error pointing to the undefined is_customer field if that's the issue.

Fixed working code

Putting it all together, here's your corrected XML:

<?xml version="1.0"?>
<odoo>
    <record id="foo_res_partner" model="ir.ui.view">
        <field name="name">Partner Extended View</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="model">res.partner</field>
        <field name="priority">100</field>
        <field name="arch" type="xml">
            <xpath expr="//notebook/page[@name='accounting']" position="after">
                <page string="Foo" name="foo" attrs="{'invisible': [('customer','=',False)]}">
                    <span>Foo</span>
                </page>
            </xpath>
        </field>
    </record>
</odoo>

内容的提问来源于stack exchange,提问作者M.E.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:15:59