Skip to content

[18.0][FIX] product_contract: search contract lines by name - #1597

Open
parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-product_contract-contract-line-name-search
Open

parabol123654 wants to merge 1 commit into
OCA:18.0from
parabol123654:18.0-fix-product_contract-contract-line-name-search

Conversation

@parabol123654

@parabol123654 parabol123654 commented Nov 12, 2026 •

Copy link
Copy Markdown

Fixes #1596.

product_contract sets _rec_name = "display_name" on contract.line. _search_display_name() searches the _rec_name field, so it builds a domain on display_name, and searching display_name calls _search_display_name() again. As a result, name_search() on contract lines never returns. It is used when typing in a many2one field to a contract line (e.g. on sale order lines) or when searching lines by name.

The display name is computed by _compute_display_name() in contract, so the _rec_name is not needed. The fix removes it, and the name search uses the name of the line, as with contract alone.

Test: test_contract_line_name_search searches the contract line of the test contract by a part of its name.

  • Without the fix: the test never ends. I stopped it after 10 minutes.
  • With the fix: the line is found. The module tests pass (35).

The same line is on 19.0; I'll forward-port the fix once this one is merged.

Assisted-by: Claude Opus 5.5

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @sbejaoui,
some modules you are maintaining are being modified, check this out!

cls.contract_line = cls.contract.contract_line_ids[0]
cls.sale.order_line._compute_product_contract_data()

def test_contract_line_name_search(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add this test. It's testing ORM.

_rec_name = "display_name" on contract.line made _search_display_name()
build a domain on display_name, which calls _search_display_name()
again: name_search() on contract lines (many2one fields, search) never
returned. The display name is computed in contract, so drop _rec_name
and let the name search use the name of the line.

Fixes OCA#1596

Assisted-by: Claude Opus 5.5
@parabol123654
parabol123654 force-pushed the 18.0-fix-product_contract-contract-line-name-search branch from 6c02da8 to fd07287 Compare November 14, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants