From 03743a714f0da3731ae2c9c361bbcab54ac6f4b0 Mon Sep 17 00:00:00 2001 From: "kdeb@odoo.com" Date: Tue, 26 Mar 2024 11:32:28 +0000 Subject: [PATCH] [FIX] crm: resolve NewId error on SO-Linked tasks Issue: - When adding opportunity/lead to a contact using Studio and attempt to add a line, we encounter the following error: "TypeError: 'NewId' object is not iterable." Steps To Reproduce (in 17.0): - In a contact form open Studio and add a O2M field Customer (Lead/Opportunity) - Try to add a line - Notice Traceback Error "TypeError: 'NewId' object is not iterable" Solution: - The issue arises in the search domain of `return_if_relevant` , exactly in ("partner_id", "child_of", lead.partner_id.commercial_partner_id.id) where the type of `lead.partner_id.commercial_partner_id.id` is NewId since the partner is being edited to add a task. This action triggers the `parse` and `to_ids` methods with a value type of NewId. thus the error. - The operator child_of expects a list of IDs, and the ids property refer to the record's origin ids. to resolve this, replace `commercial_partner_id.id` with `commercial_partner_id.ids`. opw-3760372 closes odoo/odoo#159296 Signed-off-by: Kawtar Drissi El Bouzaidi (kdeb) --- addons/crm/models/crm_lead.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 5226d19d670..068f1623bdd 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -606,7 +606,7 @@ class Lead(models.Model): # check for "same commercial entity" duplicates if lead.partner_id and lead.partner_id.commercial_partner_id: duplicate_lead_ids |= lead.with_context(active_test=False).search(common_lead_domain + [ - ("partner_id", "child_of", lead.partner_id.commercial_partner_id.id) + ("partner_id", "child_of", lead.partner_id.commercial_partner_id.ids) ]) # check the phone number duplicates, based on phone_sanitized. Only # exact matches are found, and the single one stored in phone_sanitized