Skip to content

[17.0][FIX] server_environment: set env-computed fields to readonly - #316

Open
vvrossem wants to merge 1 commit into
OCA:17.0from
camptocamp:17.0-fix-server_environment-readonly
Open

vvrossem wants to merge 1 commit into
OCA:17.0from
camptocamp:17.0-fix-server_environment-readonly

Conversation

@vvrossem

@vvrossem vvrossem commented Oct 26, 2026 •

Copy link
Copy Markdown

Backport of #227: on 17.0, fields that server_environment reads from the config are editable in forms, and whatever you type there is lost on save.

Steps to reproduce, with mail_environment installed:

  1. Set smtp_host = smtp.example.com under [outgoing_mail] in the server env config.
  2. Open an outgoing mail server and change SMTP Server to something else.
  3. Save.

The save goes through without any message, but the field comes back as smtp.example.com. It should be read-only, as it is on 19.0.

Two bugs in server_env_mixin.py, fixed the same way as in #227:

17.0 today With this PR
View hook overrides _fields_view_get, which core 17.0 no longer has, so it never runs overrides _get_view
readonly set on the field "not is_editable_field", the literal text "not x_smtp_host_env_is_editable"

Note

Other branches
19.0 already has this fix (f1f46bc). #227 for 18.0 is approved and still open.

Checks on a local 17.0 database

Config: smtp_host set under [outgoing_mail].

Check 17.0 today With this PR
smtp_host in the mail server form arch <field name="smtp_host" required="smtp_authentication != 'cli'"/> ... readonly="not x_smtp_host_env_is_editable"
Form in the browser not opened read-only, name still editable
write({"smtp_host": "typed.in.form"}) then read no error, still smtp.cfg.example
server_environment + mail_environment tests 0 failed of 17

The readonly hook overrides _fields_view_get, which core 17.0 no longer
has, so it never runs. It also set the literal string
"not is_editable_field" instead of the field name. Fields set in the
config files stayed editable in forms and edits were silently lost.

Backport of OCA#227.

(cherry picked from commit d5dc33d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:server_environment Module server_environment series:17.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants