Odoo登录用户数据不更新及11版本自定义规则配置求助
Hey there, let's break down your two Odoo problems and walk through practical fixes for each:
Issue 1: Logged-in user's data won't update
First, let's cover the most common culprits and how to check them:
Possible Causes & Fixes
- Permission conflicts:
Double-check the groups assigned to the user. Make sure their group has write access to theres.usersmodel. Also, verify if any custom record rules are blocking the user from modifying their own record—sometimes overly restrictive rules can override default permissions. Use an admin account to test editing the user's data: if the admin can update it, permissions are the issue. - Cached data:
Odoo (and your browser) caches user session data aggressively. Try a hard refresh in your browser (Ctrl+F5), or go toSettings > Technical > Actions > Clear Cachein Odoo's admin panel. If that doesn't work, restart the Odoo server to clear server-side caches. - Record lock:
If another session (like an admin editing the same user) left the record in a locked state, updates will fail. As an admin, open the user's form—if you see a "locked" indicator, unlock it or have the other user save/discard their changes. - Field or code restrictions:
If you added custom fields tores.users, check if they're set toreadonly=Truein the field definition or view. Also, if you've overridden thewritemethod in a custom module, look for logic that might be blocking saves. Check theodoo.logfile for tracebacks when you try to update—this will point to any code errors.
Issue 2: Custom record rule doesn't update after user B modifies user A's categories
This is a classic permission cache issue in Odoo. Here's what's happening and how to fix it:
Why it happens
When user A logs in, Odoo loads their permission rules (including your product category restriction) into a session cache. When user B updates user A's category field, user A's session still uses the old cached rules—so they won't see the new allowed categories until the cache is refreshed.
Fixes to try
- Force a re-login:
The simplest fix is having user A log out and back in. This triggers a full reload of their permission rules, pulling the updated category data. - Automate cache clearing with code:
You can add logic to clear the cache automatically when the category field is updated. Create a custom module and override thewritemethod forres.users:
Replacefrom odoo import models, api class ResUsers(models.Model): _inherit = 'res.users' @api.multi def write(self, vals): res = super(ResUsers, self).write(vals) # Clear cache only if the product category field is modified if 'product_categories' in vals: # Clear rule-specific cache or full environment cache self.env['ir.rule'].clear_caches() self.env.clear_caches() return resproduct_categorieswith the actual name of your Many2many field. This will refresh the permission cache whenever the category field is changed, so user A will see updates without re-logging. - Use dynamic rule domains:
If you want to avoid cache dependencies entirely, adjust your record rule's domain to dynamically pull the user's current categories. For example, set the domain to:
Odoo will evaluate this domain in real-time for each query, so it always uses the latest category values for the user—no cache refresh needed. Just note that dynamic domains can have minor performance impacts, but it's negligible for most use cases.['category_id', 'in', user.product_categories.ids]
Quick verification
After user B updates user A's categories, have user A do a hard browser refresh (Ctrl+F5) or clear Odoo's cache via the admin panel. If the product list updates, the cache was the issue.
内容的提问来源于stack exchange,提问作者Jhair Patiño




