acsone / click-odoo-contrib

Useful Odoo scripts and utility functions, based on click-odoo
GNU Lesser General Public License v3.0
105 stars 58 forks source link

click-odoo-uninstall, search for installed module only #90

Open GSLabIt opened 3 years ago

GSLabIt commented 3 years ago

Hi there,

any chance to search for installed module only? It will prevent error if module is not installed.

from: modules = env["ir.module.module"].search([("name", "in", module_names)])

to: modules = env["ir.module.module"].search([("name", "in", module_names),('state','=','installed')])

in https://github.com/acsone/click-odoo-contrib/blob/0a585efef52dc78db69702d970cdd48f1e96a1e0/click_odoo_contrib/uninstall.py#L13

sbidoul commented 3 years ago

Hi! What error do you observe? Should we include modules to upgrade too?

GSLabIt commented 3 years ago

Hi! What error do you observe? Should we include modules to upgrade too?

Error: ('One or more of the selected modules have already been uninstalled, if you believe this to be an error, you may try again later or contact support.', '')

As far as i've seen it is not needed in upgrade

sbidoul commented 3 years ago

What I mean is that a module is in state to upgrade it must be uninstalled too. So the domain you propose (state=installed) is too restrictive. Do you want to make a PR, with a test ?

GSLabIt commented 3 years ago

What I mean is that a module is in state to upgrade it must be uninstalled too. So the domain you propose (state=installed) is too restrictive. Do you want to make a PR, with a test ?

Oh, I see. so we could use state != 'uninstalled'

GSLabIt commented 3 years ago

What I mean is that a module is in state to upgrade it must be uninstalled too. So the domain you propose (state=installed) is too restrictive. Do you want to make a PR, with a test ?

I'm willing to make a pr, can u help with tests? 😬