Skip to content

[IMP] server_environment: module uninstallation - #276

Merged
OCA-git-bot merged 3 commits into
OCA:16.0from
camptocamp:16.0-server-env-module-uninstall
Aug 24, 2026
Merged

[IMP] server_environment: module uninstallation#276
OCA-git-bot merged 3 commits into
OCA:16.0from
camptocamp:16.0-server-env-module-uninstall

Conversation

@gurneyalex

Copy link
Copy Markdown
Member

Add a helper to manage the restoring of the database columns when a module using server_environment is uninstalled or the dependency on server_environment is dropped.

Document how to use the helper in an uninstall script or in an upgrade script (if a new version of the addon drops the dependency).

This is a backward port of #261

@OCA-git-bot OCA-git-bot added mod:server_environment Module server_environment series:16.0 labels Jun 29, 2026

@ivantodorovich ivantodorovich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG. Pre-commit is failing though :(

@yankinmax

Copy link
Copy Markdown
Contributor

Hello @lmignon can you pls take a look at this PR and possibly trigger merge?

@lmignon

lmignon commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-276-by-lmignon-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

@lmignon The merge process could not be finalized, because command oca-gen-addon-readme --if-source-changed --org-name OCA --repo-name server-env --branch 16.0 --addons-dir /tmp/tmpo_f2xrro --commit failed with output:

/tmp/tmpo_f2xrro/server_environment/README.rst:226: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
Traceback (most recent call last):
  File "/usr/local/bin/oca-gen-addon-readme", line 6, in <module>
    sys.exit(gen_addon_readme())
             ^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 1569, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 1490, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 1353, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/click/core.py", line 907, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/src/oca-maintainers-tools/tools/gen_addon_readme.py", line 575, in gen_addon_readme
    check_rst(readme_filename)
  File "/ocamt/src/oca-maintainers-tools/tools/gen_addon_readme.py", line 398, in check_rst
    publish_file(
  File "/ocamt/lib/python3.12/site-packages/docutils/core.py", line 465, in publish_file
    output, _publisher = publish_programmatically(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/core.py", line 794, in publish_programmatically
    output = publisher.publish(enable_exit_status=enable_exit_status)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/core.py", line 269, in publish
    self.document = self.reader.read(self.source, self.parser,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/readers/__init__.py", line 95, in read
    self.parse()
  File "/ocamt/lib/python3.12/site-packages/docutils/readers/__init__.py", line 101, in parse
    self.parser.parse(self.input, document)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/__init__.py", line 185, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 182, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 234, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 446, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 1277, in indent
    elements = self.block_quote(indented, line_offset)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 1294, in block_quote
    self.nested_parse(blockquote_lines, line_offset, blockquote)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 357, in nested_parse
    my_state_machine.run(block, input_offset, self.memo,
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 215, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 234, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 446, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2867, in indent
    dl_item, blank_finish = self.definition_list_item(context)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2998, in definition_list_item
    self.nested_parse(indented, input_offset=line_offset, node=dd)
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 357, in nested_parse
    my_state_machine.run(block, input_offset, self.memo,
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 215, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 234, in run
    context, next_state, result = self.check_line(
                                  ^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/statemachine.py", line 446, in check_line
    return method(match, context, next_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 2878, in indent
    self.parent += self.unindent_warning('Definition list')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/parsers/rst/states.py", line 543, in unindent_warning
    return self.reporter.warning('%s ends without a blank line; '
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/utils/__init__.py", line 248, in warning
    return self.system_message(self.WARNING_LEVEL, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ocamt/lib/python3.12/site-packages/docutils/utils/__init__.py", line 217, in system_message
    raise SystemMessage(msg, level)
docutils.utils.SystemMessage: /tmp/tmpo_f2xrro/server_environment/README.rst:226: (WARNING/2) Definition list ends without a blank line; unexpected unindent.

@yankinmax

Copy link
Copy Markdown
Contributor

@lmignon what can I do to fix this issue? Do you have any idea?

@lmignon

lmignon commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

@lmignon what can I do to fix this issue? Do you have any idea?

Generate the files locally to see the result a line 226 and try to resolve the format into the source document to avoid warnings. 🤔

@OCA-git-bot OCA-git-bot added the mod:mail_environment Module mail_environment label Aug 24, 2026
@yankinmax

Copy link
Copy Markdown
Contributor

I've added here two backport commits of the:

This is needed to be able to add this PR as a dependency to another PR's without conflicts like this one:

ERROR: Cannot install odoo-addon-server-environment 16.0.1.1.2.6 (from git+https://github.com/OCA/server-env.git@refs/pull/276/head#subdirectory=setup/server_environment) and odoo-addon-server-environment 16.0.1.1.2.6 (from git+https://github.com/OCA/server-env.git@refs/pull/287/head#subdirectory=setup/server_environment) because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested odoo-addon-server-environment 16.0.1.1.2.6 (from git+https://github.com/OCA/server-env.git@refs/pull/276/head#subdirectory=setup/server_environment)
    The user requested odoo-addon-server-environment 16.0.1.1.2.6 (from git+https://github.com/OCA/server-env.git@refs/pull/287/head#subdirectory=setup/server_environment)

This conflict is happening, because in v16 we can't have two test dependencies pointing to the same module (from what I see).
Like this

odoo-addon-server_environment @ git+https://github.com/OCA/server-env.git@refs/pull/276/head#subdirectory=setup/server_environment
odoo-addon-server_environment @ git+https://github.com/OCA/server-env.git@refs/pull/287/head#subdirectory=setup/server_environment

Once this PR is merged I'll close this one:

@yankinmax
yankinmax force-pushed the 16.0-server-env-module-uninstall branch from af4348a to 567c760 Compare August 24, 2026 12:54
@yankinmax

Copy link
Copy Markdown
Contributor

@lmignon The merge process could not be finalized, because command oca-gen-addon-readme --if-source-changed --org-name OCA --repo-name server-env --branch 16.0 --addons-dir /tmp/tmpo_f2xrro --commit failed with output:

Hello @lmignon , this should be solved



@openupgrade.migrate()
def migrate(env, version):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you intend to run this on the next upgrade? The current version is 1.1.1 and this won't have any effect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 16.0.1.0.2:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I've probably checked the wrong branch.

BTW next time you can bump the version manually and we can use nobump on merge. This way you have full control.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was asked several times on different PR's not to bump 😄

@yankinmax
yankinmax force-pushed the 16.0-server-env-module-uninstall branch from 567c760 to 88e0488 Compare August 24, 2026 13:21
gurneyalex and others added 3 commits August 24, 2026 16:23
Add a helper to manage the restoring of the database columns when a
module using `server_environment` is uninstalled or the dependency on
`server_environment` is dropped.

Document how to use the helper in an uninstall script or in an upgrade
script (if a new version of the addon drops the dependency).
Helper function typically used for hooks and migration scripts.
Restores database values for fields transitioning to 'server env managed'.

When a field is defined as managed by the server environment, Odoo
ignores the value stored in the database, prioritizing the environment
configuration instead. If no environment configuration exists, the field
may effectively lose its previous value.

This method forces to 'persist' these values if they are not
explicitly overridden by the current environment configuration.
…cation"

To preserve the value of field "smtp_authentication" if we don't set it from
the environment.
Which may happen to anyone updating the sources of mail_environment for its project.
@yankinmax
yankinmax force-pushed the 16.0-server-env-module-uninstall branch from 88e0488 to 115290d Compare August 24, 2026 13:23
@simahawk

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-276-by-simahawk-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit b94e7f0 into OCA:16.0 Aug 24, 2026
5 of 7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at e2d94da. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants