Skip to content

[WIP][16.0] partner_multi_relation improvements#2246

Open
NL66278 wants to merge 10 commits intoOCA:16.0from
Therp:16.0-partner_multi_relation-improvements
Open

[WIP][16.0] partner_multi_relation improvements#2246
NL66278 wants to merge 10 commits intoOCA:16.0from
Therp:16.0-partner_multi_relation-improvements

Conversation

@NL66278
Copy link
Copy Markdown
Contributor

@NL66278 NL66278 commented Dec 30, 2025

backport 18.0 / 19.0 simplification. Not to be merged but available for whoever wants or needs it.

@NL66278 NL66278 force-pushed the 16.0-partner_multi_relation-improvements branch 9 times, most recently from 62c29ad to 3011196 Compare January 2, 2026 10:32
@NL66278 NL66278 force-pushed the 16.0-partner_multi_relation-improvements branch from ce17ced to 489e8c7 Compare January 6, 2026 15:18
Copy link
Copy Markdown

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

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

Automated Review -- Tests Failed

1. Root Cause of the Test Failure

The test failure occurs because the migration script attempts to drop SQL views (res_partner_relation_all and res_partner_relation_type_selection) that no longer exist in the current version of the module. These views were removed in the refactoring but the post-migration script still tries to drop them, leading to a database error during the upgrade process.

2. Suggested Fix

In partner_multi_relation/migrations/16.0.2.0.0/post-migration.py, remove the lines that attempt to drop res_partner_relation_type_selection view since it was never removed from the codebase in this PR, and only keep the drop for res_partner_relation_all if it's truly gone:

# partner_multi_relation/migrations/16.0.2.0.0/post-migration.py

# Remove this line if res_partner_relation_type_selection was never removed:
# env.cr.execute("DROP VIEW IF EXISTS res_partner_relation_type_selection;")

# Keep this line only if res_partner_relation_all was actually removed:
env.cr.execute("DROP VIEW IF EXISTS res_partner_relation_all;")

Line numbers: Lines 10–11 in post-migration.py

3. Additional Code Issues

  • Missing @api.model decorator on _get_current_partner(): This method is used in @api.depends_context computed fields, but it's not decorated with @api.model, which is required for methods called via self.env in computed fields.

    File: partner_multi_relation/models/res_partner_relation.py
    Line: ~473
    Fix: Add @api.model before _get_current_partner().

  • Incorrect usage of AND in _search_relation_date: The method uses AND to combine domains, but AND is a function from odoo.osv.expression, and should be used properly with list of domains.

    File: partner_multi_relation/models/res_partner.py
    Lines: ~114–116
    Fix: Ensure that the domain construction is valid, and consider using AND correctly with PartnerRelation.search() or domain building logic.

4. Test Improvements

To better cover the changed logic, add the following test cases:

  • Test _search_relation_type_id with various operators (=, !=, in, not in, like, ilike, etc.) to ensure that unsupported operators raise ValidationError.

    Pattern: Use TransactionCase or SavepointCase and assert ValidationError is raised.

  • Test action_view_relations to ensure it correctly returns the action with domain filtering on left_partner_id or right_partner_id.

    Pattern: Use SavepointCase to test the returned action dictionary, checking domain and context.

  • Test _compute_left_partner_id_domain, _compute_right_partner_id_domain, and _compute_type_id_domain with various combinations of relation type and partner to ensure correct filtering domains are computed.

    Pattern: Use TransactionCase or SavepointCase to create test data and assert domain values.

  • Test name_get and _compute_display_name to verify that names are correctly computed, especially when current_partner_id is set in the context.

    Pattern: Use SavepointCase to simulate context and assert computed name strings.

These tests should be tagged with @tag('post_install') or @tag('multi_relation') for better organization in OCA test suites.


⏰ This PR has been open for 75 days.
🔍 No human reviews yet after 75 days. PSC members: a quick review would help keep this contributor engaged with OCA.
💤 Last activity was 68 days ago.

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward. Thank you!


Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

@NL66278 NL66278 force-pushed the 16.0-partner_multi_relation-improvements branch from 489e8c7 to 584182a Compare March 31, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants