[WIP][16.0] partner_multi_relation improvements#2246
[WIP][16.0] partner_multi_relation improvements#2246
Conversation
62c29ad to
3011196
Compare
ce17ced to
489e8c7
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
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.modeldecorator on_get_current_partner(): This method is used in@api.depends_contextcomputed fields, but it's not decorated with@api.model, which is required for methods called viaself.envin computed fields.File:
partner_multi_relation/models/res_partner_relation.py
Line: ~473
Fix: Add@api.modelbefore_get_current_partner(). -
Incorrect usage of
ANDin_search_relation_date: The method usesANDto combine domains, butANDis a function fromodoo.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 usingANDcorrectly withPartnerRelation.search()ordomainbuilding logic.
4. Test Improvements
To better cover the changed logic, add the following test cases:
-
Test
_search_relation_type_idwith various operators (=,!=,in,not in,like,ilike, etc.) to ensure that unsupported operators raiseValidationError.Pattern: Use
TransactionCaseorSavepointCaseand assertValidationErroris raised. -
Test
action_view_relationsto ensure it correctly returns the action with domain filtering onleft_partner_idorright_partner_id.Pattern: Use
SavepointCaseto test the returned action dictionary, checking domain and context. -
Test
_compute_left_partner_id_domain,_compute_right_partner_id_domain, and_compute_type_id_domainwith various combinations of relation type and partner to ensure correct filtering domains are computed.Pattern: Use
TransactionCaseorSavepointCaseto create test data and assert domain values. -
Test
name_getand_compute_display_nameto verify that names are correctly computed, especially whencurrent_partner_idis set in the context.Pattern: Use
SavepointCaseto 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:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
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
Instead of a SQL view that shows relatiosn from two sides, we will have a simple model, and a simple UI view, that however will adapt to from which partner relations are shown.
489e8c7 to
584182a
Compare
backport 18.0 / 19.0 simplification. Not to be merged but available for whoever wants or needs it.