[FIX] survey_record_generation: link to already created record at creation #29

Merged
mondot merged 2 commits from survey_record_generation-fix-other-record-overriding-computed-values into 18.0 2026-10-23 08:54:49 +00:00
Owner

cf https://elabore.coop/odoo/project.task/6803 pour la demande fonctionnelle (il s'agit de pouvoir mettre un montant libre pour les abonnements générés par les réponses au sondage d'adhésion de Négawatt).

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.

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

cf https://elabore.coop/odoo/project.task/6803 pour la demande fonctionnelle (il s'agit de pouvoir mettre un montant libre pour les abonnements générés par les réponses au sondage d'adhésion de Négawatt). 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. 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 reviewed 2026-10-22 08:05:36 +00:00
@@ -1075,0 +1124,4 @@
original_write = partner_class.write
written_fields = []
def spy_write(records, vals):
Author
Owner

Problème de design de checker le write ?

Problème de design de checker le write ?
mondot marked this conversation as resolved
mondot changed target branch from new-survey_dropdown_simple_choice-module to 18.0 2026-10-22 16:38:45 +00:00
mondot added 3 commits 2026-10-22 16:38:45 +00:00
[ADD] survey_dropdown_simple_choice
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m48s
tests / test (pull_request) Successful in 1m35s
dfaaa9405c
Display "Multiple choice: only one answer" (simple_choice) survey
questions as a dropdown list instead of radio buttons, per question.

The select is mirrored on hidden radios so that the native survey form
pipeline (validation, conditional questions, "Other" comment, AJAX
submit, correct answers display) keeps working. Native radio rendering
is kept when suggested answers contain images and in readonly mode.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
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 1m42s
cd6261b34a
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 added 2 commits 2026-10-22 16:41:07 +00:00
[FIX] survey_record_generation: questions without answer no longer empty fields
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m42s
cd6261b34a
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>
[FIX] survey_record_generation: questions without answer no longer empty fields
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m36s
tests / test (pull_request) Successful in 1m15s
3c8976d51b
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>
stephansainleger approved these changes 2026-10-23 08:29:26 +00:00
mondot merged commit 0020f35399 into 18.0 2026-10-23 08:54:49 +00:00
mondot deleted branch survey_record_generation-fix-other-record-overriding-computed-values 2026-10-23 08:54:49 +00:00
Sign in to join this conversation.
No description provided.