Odoo v10 HR模块自定义联系表单:新增字段值无法同步至申请人档案
Hey Elena, I’ve run into this exact issue a few times when adding custom fields to Odoo’s website forms—let’s go through the most likely fixes step by step:
Verify Field Mapping in the Website Form
This is the #1 culprit. Odoo doesn’t automatically map frontend form fields to backend model fields unless you explicitly set it up. Here’s how to check:- Go to your website form’s configuration (in the backend, navigate to the form edit page).
- Look for the Field Mappings section (you might need to enable developer mode to see this if it’s hidden).
- Add a new mapping entry: set the Input Name to
x_surname(matching your frontend input’snameattribute) and select your backendx_surnamefield (under thecrm.leadmodel) as the Field. - Save the form settings and test again.
Check Field Permissions for Public Users
If your backendx_surnamefield doesn’t allow public users (the ones submitting the form) to write to it, Odoo will silently drop the value. To fix this:- Enable developer mode, then go to Settings > Technical > Models and search for
crm.lead. - Open the
x_surnamefield’s configuration. - In the Access Rights tab, make sure the Public user group has at least Write permission (you can check both Read and Write to be safe).
- Save the field settings.
- Enable developer mode, then go to Settings > Technical > Models and search for
Ensure No Custom Controller Overrides Are Blocking the Field
If you’re using a custom controller to handle form submissions instead of Odoo’s default, you need to explicitly handle thex_surnameparameter. For example, in your controller code, you should have something like:lead = request.env['crm.lead'].sudo().create({ 'name': request.params.get('name'), 'email_from': request.params.get('email'), 'x_surname': request.params.get('x_surname'), # Make sure this line exists! # ... other fields })If this line is missing, the surname value won’t be saved to the lead.
Clear Caches and Retest
Odoo loves to cache field definitions and form configurations. After making any of the above changes:- Clear your browser’s cache and hard-refresh the form page.
- In the Odoo backend, go to Settings > Technical > Actions > Clear Cache (or use the developer mode’s refresh button at the top right).
- Submit a test form with a surname to see if it syncs now.
Double-Check Frontend Field Name
Your frontend code usesname="x_surname"which matches the backend field name—good! Just make sure there are no typos (case sensitivity matters here; Odoo field names are lowercase, so you’re set).
Give these steps a try, and I bet one of them will fix the sync issue. Let me know if you hit any snags!
内容的提问来源于stack exchange,提问作者Elena

