odoo/odoo#159544

Created by fw-bot
label
odoo-dev:saas-17.1-17.0-OPW-3760372-crm_child_of_search_error-kdeb-ICz4-fw
head
30685b5245027a5ce1fab2b73b055de3132d8ae7
target
saas-17.1
merged
1 month ago by Kawtar Drissi El Bouzaidi (kdeb)
forward-port of
odoo/odoo#159296

[FW][FIX] crm: resolve NewId error linking opportunity to contact via studio

## 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 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

---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: odoo/odoo#159296