跳至內容
選單
此問題已被標幟
1 回覆
223 瀏覽次數

In crm.lead model, I created custom field city (many2one with custom model- x_cities) , In odoo online, dynamic domain filtering is not working to show only cities of the selected state in crm.lead and onchange, or computed fields are also not allowed in Odoo Online.anyone has any workaround for this?


頭像
捨棄
最佳答案

Hi,

Use a domain in Studio for the city_id field like [('state_id', '=', state_id)], which sometimes works even in Odoo Online.


Create a related field in Studio (e.g., lead_state_id) pointing to state_id, and use it in the domain: [('state_id', '=', lead_state_id)].


Use server actions as a workaround to set a default city_id based on the selected state_id, since @api.onchange is not allowed in Odoo Online.


Odoo Online does not support computed fields or onchange methods, so dynamic domain logic must rely only on UI-based filtering or automation.


Limit city records in your x_cities model and prefix city names with state codes (e.g., "KL - Kochi") to make manual selection easier.


Use conditional visibility or multiple city fields (one per state group) if absolutely needed as a visual workaround.


Inform users to manually choose the correct city, or guide them with tooltips or help text, until full filtering is available through a custom module in Odoo.sh or On-Premise.


Hope it helps.

頭像
捨棄