[16.0][FIX] survey_record_generation: backport fixes on linked records and unanswered questions #32

Merged
mondot merged 2 commits from 16.0-backport-survey_record_generation-fixes into 16.0 2026-11-17 14:15:13 +00:00
Owner

Backport from 18.0 of bfe5909 and 0020f35.

A NOT required "other_record" field was always set after the loop with a
write(), even when the linked record was already created. This late write
triggers the recomputation of stored computed fields depending on the
relation, overriding the values answered by the user (e.g. with
subscription_oca, a free amount typed by the participant on a
sale.subscription.line was replaced by the product price).

The relation is now given to create() when the linked record already
exists. The deferred write is kept for records created later.

Questions without answer no longer empty fields (0020f35)

When a question was not displayed (conditional question) or skipped, its
field was still given to create() with a None value, emptying the field
instead of keeping its default or computed value.

Fields without value are now left out, which also allows several
conditional questions to fill up the same field.

Backport notes

  • Version bumped to 16.0.1.0.4.
  • Tests: new test_computed_fields (fake models via odoo_test_helper)
    and 2 new tests in test_survey_record_creation.
  • Tested in the rc_16.0-ELABORE-LIGHT image: 28 tests, 0 failed, 0 error.
Backport from 18.0 of bfe5909 and 0020f35. ## Link to already created record at creation (bfe5909) A NOT required "other_record" field was always set after the loop with a `write()`, even when the linked record was already created. This late write triggers the recomputation of stored computed fields depending on the relation, overriding the values answered by the user (e.g. with subscription_oca, a free amount typed by the participant on a `sale.subscription.line` was replaced by the product price). The relation is now given to `create()` when the linked record already exists. The deferred write is kept for records created later. ## Questions without answer no longer empty fields (0020f35) When a question was not displayed (conditional question) or skipped, its field was still given to `create()` with a `None` value, emptying the field instead of keeping its default or computed value. Fields without value are now left out, which also allows several conditional questions to fill up the same field. ## Backport notes - Version bumped to `16.0.1.0.4`. - Tests: new `test_computed_fields` (fake models via `odoo_test_helper`) and 2 new tests in `test_survey_record_creation`. - Tested in the `rc_16.0-ELABORE-LIGHT` image: 28 tests, 0 failed, 0 error.
mondot changed target branch from 18.0 to 16.0 2026-11-17 14:14:40 +00:00
mondot added 2 commits 2026-11-17 14:14:40 +00:00
A NOT required "other_record" field was always set after the loop with a
write(), even when the linked record was already created. This late write
triggers the recomputation of stored computed fields depending on the
relation, overriding the values answered by the user.

E.g. with subscription_oca, sale.subscription.line price_unit depends on
sale_subscription_id.partner_id/pricelist_id: a free amount typed in a
numerical_box question (33) was replaced by the product price (20) when
the line was linked to its subscription.

Now the relation is given to create() when the linked record already
exists, so that the user's values are protected from recomputation. The
deferred write is kept for records created later.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
[FIX] survey_record_generation: questions without answer no longer empty fields
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m54s
0a7f7213f4
When a question was not displayed (conditional question) or skipped, its
field was still given to create() with a None value. The field was then
emptied instead of keeping its default or computed value.

Since the link to an already created record is given at creation, this
also made sale.subscription.line price_unit equal to 0 when the "free
amount" question was not displayed, instead of the product price.

Fields without value are now left out of the values, which also allows
several conditional questions to fill up the same field (e.g. one list
of amounts per periodicity).

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
mondot merged commit 0a7f7213f4 into 16.0 2026-11-17 14:15:13 +00:00
mondot deleted branch 16.0-backport-survey_record_generation-fixes 2026-11-17 14:15:14 +00:00
Sign in to join this conversation.
No description provided.