[FIX] project_average_acceptable_time: use on_account_update hook #37

Merged
stephansainleger merged 1 commits from 18.0-project-average-acceptable-time-portal-fix into 18.0 2026-11-12 16:36:21 +00:00

The portal override validated the submitted data a second time after
super().account() returned. When the partner cannot edit its VAT (child
contact or issued invoices), the country select is disabled and not
submitted; Odoo core injects the missing country_id in its own copy of
the posted data, but the raw payload re-validated by the module still
lacked it, raising KeyError: 'country_id' and a 500 on save.

Move the default-project update to on_account_update(), which Odoo
calls after a successful validation, and drop the duplicate validation.
Add a regression test with a child contact whose country field is disabled.

The portal override validated the submitted data a second time after ``super().account()`` returned. When the partner cannot edit its VAT (child contact or issued invoices), the country select is disabled and not submitted; Odoo core injects the missing ``country_id`` in its own copy of the posted data, but the raw payload re-validated by the module still lacked it, raising ``KeyError: 'country_id'`` and a 500 on save. Move the default-project update to ``on_account_update()``, which Odoo calls after a successful validation, and drop the duplicate validation. Add a regression test with a child contact whose country field is disabled.
stephansainleger added 1 commit 2026-11-10 22:07:16 +00:00
[FIX] project_average_acceptable_time: use on_account_update hook
Some checks failed
pre-commit / pre-commit (pull_request) Failing after 1m23s
tests / test (pull_request) Successful in 2m39s
dbb5711ae9
The portal override validated the submitted data a second time after
``super().account()`` returned. When the partner cannot edit its VAT (child
contact or issued invoices), the country select is disabled and not
submitted; Odoo core injects the missing ``country_id`` in its own copy of
the posted data, but the raw payload re-validated by the module still
lacked it, raising ``KeyError: 'country_id'`` and a 500 on save.

Move the default-project update to ``on_account_update()``, which Odoo
calls after a successful validation, and drop the duplicate validation.
Add a regression test with a child contact whose country field is disabled.
Author
Owner

revue faite par Claude Opus 5.5 (réflexion au niveau par défaut), qui a lu le code sans lancer les tests :

Diagnostic confirmé par Opus : quand can_edit_vat() est faux, le core Odoo 18 ajoute country_id dans sa propre copie de post (portal.py l.189-190). La copie re-validée par le module ne l'a pas, d'où le KeyError.
Passer par on_account_update() lui paraît la bonne approche : le core ne l'appelle qu'après une validation réussie (l.204), et average_acceptable_time est bien dans values via _get_optional_fields().
Le test de non-régression (contact rattaché à une société, sans country_id) couvre le cas.

Verdict d'Opus : OK pour merger.

revue faite par Claude Opus 5.5 (réflexion au niveau par défaut), qui a lu le code sans lancer les tests : Diagnostic confirmé par Opus : quand `can_edit_vat()` est faux, le core Odoo 18 ajoute `country_id` dans sa propre copie de post (portal.py l.189-190). La copie re-validée par le module ne l'a pas, d'où le KeyError. Passer par `on_account_update()` lui paraît la bonne approche : le core ne l'appelle qu'après une validation réussie (l.204), et `average_acceptable_time` est bien dans values via `_get_optional_fields()`. Le test de non-régression (contact rattaché à une société, sans `country_id`) couvre le cas. Verdict d'Opus : OK pour merger.
stephansainleger merged commit dbb5711ae9 into 18.0 2026-11-12 16:36:21 +00:00
stephansainleger deleted branch 18.0-project-average-acceptable-time-portal-fix 2026-11-12 16:36:21 +00:00
Sign in to join this conversation.
No description provided.