[18.0][ADD] webservice_server_env: make server_environment an optional dependency - #146
[18.0][ADD] webservice_server_env: make server_environment an optional dependency#146yankinmax wants to merge 3 commits into
Conversation
|
Hi @etobella, |
|
Hello @dreispt @ivantodorovich @simahawk can you pls take a look? |
0ee7047 to
4a4462c
Compare
4a4462c to
cf1e2e4
Compare
cf1e2e4 to
59f2570
Compare
|
@ivantodorovich I've updated this PR with backport commit of uninstall hook to be consistent with v19 |
|
This PR has the |
| [("name", "=", "webservice_server_env"), ("state", "=", "uninstalled")] | ||
| ) | ||
| if module: | ||
| module.button_install() |
There was a problem hiding this comment.
in the case that the module is not added, can you provide the uninstall hook to pass all data?
There was a problem hiding this comment.
in the migration should be there if the other module is not installed (it does not exist)
in some cases that could happen if you only add the modules
There was a problem hiding this comment.
What do you mean?
In general we should have two cases:
webserviceis already installed in the database (meaning current database version of the module depends onserver_environment): thenwebserviceupgrade will remove the dependency and upgrade hook will installwebservice_server_env.webserviceis not installed and this is a brand new installation: ifserver_environmentis installed thenwebservice_server_envwill be auto installed, because ofauto_installkey in manifest.
In both cases if you decide to uninstallserver_environmentandwebservice_server_envthe uninstall hook will make the fields regular for thewebservice.
Can you pls describe the case I need to handle?
There was a problem hiding this comment.
No, there is a 3rd case (and it happened to me with fs_storage).
You have server_environment and webservice installed. On the update, you don't know that you need the new module, and you don't add it (I use doodba, and I specify exactly the modules I need). On the update, the if is false, as the module is not found, then, you loose all data, leaving your instance without the credentials.
We have 2 options:
1- raise an exception if the module is not found
2- Make it in a way that the module restores data in case the module is not found.
There was a problem hiding this comment.
You have server_environment and webservice installed. On the update, you don't know that you need the new module, and you don't add it
I thought it's actually covered by Odoo with auto_install: if you potentially specify the list of modules to install, the web-api submodule is present on a branch revision (or even aggregated one is built on top of the branch revision), so you definitely have in the code source the webservice_server_env, then even if you don't force it in the list it should be auto installed.
Am I not right?
There was a problem hiding this comment.
Yes, but that implies that the module is there. A lot of people is adding the whole branch of modules of the OCA repository, but that is not mandatory. That happened to me, with a system that uses git-aggregate and a process to get only the necessary modules. That could happen to if you use PyPi too. Doing this kind of activities (limiting the modules) allows us to be sure that the modules in the instance are compatible and allows us to make some tests on the instance before pushing it.
There was a problem hiding this comment.
ok, I see....but I still can't get what kind of uninstall hook I need to add. Can you pls suggest the pseudo-code idea?
There was a problem hiding this comment.
Something like this:
Another option is to raise an Exception, this way this problem is avoided.
There was a problem hiding this comment.
@etobella WDYT:
def migrate(env, version):
module = env["ir.module.module"].search([("name", "=", "webservice_server_env")])
if not module:
raise exceptions.UserError(
_(
"The 'webservice_server_env' module is not available. "
"It is required to preserve the server environment managed "
"fields of 'webservice.backend'. Make it available on the "
"addons path before upgrading 'webservice'."
)
)
if module.state == "uninstalled":
module.button_install()
b175404 to
a684bdb
Compare
This PR is opened to speed up and replace work started on this PR:
Applied @ivantodorovich request:
PR is aimed to remove
server_environmentdependency fromwebservicein the scope of this issue:Backport
server_environmentuninstall hook:webservice_server_env: uninstall hook #141Depends on: