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

Odoo创建记录后模型Tree View仍空白问题排查求助

Troubleshooting: Odoo Tree View Not Showing Created Records for payroll.job

Let's walk through the most likely issues and fixes based on your code and common Odoo gotchas:

1. Missing Default Value for active Field (Top Suspect)

Looking at your model definition:

active = fields.Boolean()

Odoo’s Tree Views automatically filter out records where active = False by default. Since you didn’t set a default value for this field, any new record you create will have active = False out of the box—so they’ll be hidden from the Tree View unless you manually adjust the filter.

Fix this by adding a default True value to the active field:

active = fields.Boolean(default=True)

After updating the code, upgrade your module, create a new record, and check if it appears in the Tree View.

2. Double-Check Permissions & Access Rules

Your security rules look correct on paper (hr.group_hr_manager has full access, base.group_user has read access), but let’s confirm a few things:

  • Are you logged in as a user who belongs to hr.group_hr_manager (or a group with equivalent permissions)? Regular users with only base.group_user access should still see records, but make sure there are no extra ir.rule records restricting access to payroll.job entries.
  • Did you upgrade your module after adding the security rules? Odoo won’t apply new security settings until you refresh the module.

3. Check for View Priority Conflicts

Your Tree View has a priority of 8:

<field eval="8" name="priority"/>

If another module has a Tree View for payroll.job with a higher priority (lower number—priority 1 takes precedence over 8), that view will be used instead of yours. To verify:

  • Go to Settings > Technical > User Interface > Views, search for payroll.job, and check if there are other Tree Views with a lower priority number.
  • You can either lower your view’s priority (e.g., eval="1") or disable any conflicting views.

4. Ensure Module Upgrade & Cache Refresh

Don’t overlook the basics: after making changes to models, views, or security rules, you must upgrade your module in Odoo. Also, clear your browser cache and hard-refresh the page (Ctrl+F5) to ensure the latest view definitions load properly.

5. Quick Note on _rec_name

While this won’t prevent records from showing up, your _rec_name = 'job_id' depends on the linked hr.job record’s name. If you create a payroll.job entry without selecting a job_id, the record’s display name will be empty—but it should still appear in the Tree View (just with a blank name). This is more of a usability tweak than a fix for missing records.


内容的提问来源于stack exchange,提问作者A.Sasori

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 16:28:12