Skip to content

Conversation

@atgalvez08
Copy link

@atgalvez08 atgalvez08 commented Jan 9, 2026

@BinhexTeam

Problem

The test suite of the module account_invoice_supplierinfo_update fails on Odoo 16 during CI execution (Codecov / runbot).

The failure occurs in test_get_the_right_variant_supplierinfo, when writing a new product variant on an existing invoice line:
• The test passes a recordset to a many2one field (product_id) in a write() call.
• In Odoo 16, the accounting framework (account.move._field_will_change) strictly expects IDs (integers) in write() values.
• This results in a type mismatch and causes the test to fail with warnings and errors during coverage execution.

Root Cause

In Odoo 16, the method _field_will_change() compares:
record[field_name].id != vals[field_name]

When vals[field_name] is a recordset instead of an integer, the comparison becomes invalid and triggers a runtime warning / failure.

The test was implicitly relying on older permissive behavior, which is no longer valid in Odoo 16.

Solution

Update the test to comply with the Odoo ORM API by always passing IDs (integers) when writing to many2one fields.

Specifically:
• Replace the recordset assignment to product_id with its .id.

This is a minimal, safe, and fully backward-compatible fix that restores test stability without altering any functional behavior.

Implementation Details
• Update the failing test to write product_id as an integer:
self.line_a.write({"product_id": product_a_2.id, "price_unit": 400})

•	No changes are made to business logic, models, or wizards.
•	The fix is limited strictly to the test code.

Tests
• Existing tests now pass successfully on Odoo 16.
• No new tests were required, as this change restores correctness in an existing regression test.

Scope & Compatibility
• Test-only fix.
• No functional or behavioral changes.
• Fully compatible with Odoo 16 and aligned with OCA coding standards.
• Prevents CI and Codecov failures.

Conclusion

This PR fixes a test incompatibility introduced by stricter ORM behavior in Odoo 16 by ensuring that many2one fields are written using integer IDs, as required by the framework.

The change is minimal, correct, and keeps the test suite reliable and CI-safe.

@OCA-git-bot
Copy link
Contributor

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

…tests

Fix tests failing on Odoo 16 because product_id must be written as an integer id, not a recordset.
@atgalvez08 atgalvez08 force-pushed the 16.0-fix-account_invoice_supplierinfo_update branch from aa26e18 to 69a5d8e Compare January 23, 2026 09:44
@atgalvez08 atgalvez08 marked this pull request as ready for review January 23, 2026 09:55
@jelenapoblet
Copy link

@rrebollo @antoniodavid could you please review this ? thanks

Copy link

@rrebollo rrebollo left a comment

Choose a reason for hiding this comment

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

Code Review. LGTM! Good catch.

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.

4 participants