[19.0] [FIX] partner_stage: rename res_partner.state -> stage_state#2367
[19.0] [FIX] partner_stage: rename res_partner.state -> stage_state#2367bosd wants to merge 1 commit into
Conversation
|
Hi @dreispt, |
BhaveshHeliconia
left a comment
There was a problem hiding this comment.
Functional LGTM,
But last digit should be increased in manifest version for fix PRs
f37c4f5 to
bc17147
Compare
|
Addressed the review: bumped the manifest to a major version |
bc17147 to
1a42cc2
Compare
|
Heads-up on a small but important change in the latest push: I made the migration idempotent / self-healing instead of a plain rename. The simple |
|
Good for me, please check the test build. |
The stored related res.partner.state field collided with
account_move.state in Odoo Enterprise's account_reports VAT report
SQL (_check_suite_common_vat_report), which issues an unqualified
WHERE state = 'posted' against a JOIN of account_move and
res_partner. Postgres bailed with::
column reference "state" is ambiguous
Renamed the field (and its Postgres column) to stage_state. The
field still exists with the same store / related / readonly
semantics, just under a more specific name that does not collide
with downstream queries. Pre-migrate handles the column rename for
existing installations.
The companion init_hook write was updated to use the new column
name. Internal view references on res.partner.stage.state are
unaffected (different model).
1a42cc2 to
57ae13a
Compare
|
Pushed a test for the migration (tests/test_migration.py) covering all three reconciliation branches (state-only → rename, both → drop legacy, stage_state-only → noop) — the schema changes run inside the test transaction and roll back. This restores coverage (codecov/project) and re-triggers CI; the earlier red 'test with Odoo' was a flaked 'Initialize containers' (Docker/Postgres) step, not a test failure. |
partner_stage now exposes the partner stage value as `stage_state` (res_partner.`state` was renamed to avoid the AmbiguousColumn collision with account_move.state in the enterprise VAT report — see OCA#2367). Update the injected Many2one domain and the tests to filter on `stage_state`. Depends on OCA#2367
partner_stage now exposes the partner stage value as `stage_state` (res_partner.`state` was renamed to avoid the AmbiguousColumn collision with account_move.state in the enterprise VAT report — see OCA#2367). Update the injected Many2one domain and the tests to filter on `stage_state`. Depends on OCA#2367
Summary
The stored related field
res.partner.state(added inpartner_stage/models/res_partner.py) collides withaccount_move.statein Odoo Enterprise'saccount_reportsVAT report SQL.account_reports.account_return._check_suite_common_vat_reportissues:The unqualified
state = 'posted'matches bothmove.stateandpartner.stateoncepartner_stageis installed, and Postgres raises:This breaks the VAT closing checks on any deployment that combines
partner_stagewith Odoo Enterprise'saccount_reports.Fix
Rename the field to
stage_state— same store / related / readonly semantics, more descriptive name, no collision with downstream queries.models/res_partner.py: field renamed.migrations/19.0.1.2.0/pre-migrate.py: renames the Postgres column fromstatetostage_statefor existing installations (idempotent guard against installations that already havestage_statefrom a fresh install or a re-run).init_hook.py: the post-install SQL writes to the new column name.Test plan
stage_state, init_hook populates default stage cleanly.statecolumn tostage_state; data preserved.stage_statealready exists.account_reports: VAT report closing checks now run without anAmbiguousColumnerror. (Verified by the maintainer on an FLC production database; PR-side CI does not have enterprise.)Breaking change
The field is renamed. Any third-party that reads
res.partner.statedirectly (rather than the canonicalres.partner.stage_id.state) needs to follow the rename. A pre-migration could not be more clever than this without making assumptions about external consumers.