Please sign in to comment.
[FIX] mrp: avoid module warning when a group is removed
Due to a weird combination of dependencies and settings, the behaviour of the workorder checkbox in the MRP configuration wizard is a bit dangerous: - if the group is enabled via another mechanism (e.g. a technical view) before accessing the wizard, the default is set to True and an invisible `module_mrp_workorder` field is enabled, promptly causing the installation of the module upon saving (although the user did not modify a single thing in the wizard) - if the module was installed through another mechanism (e.g. the apps menu) but the group was disabled, accessing the wizard will cause the group to get unchecked, promptly causing the removal of your module and all its data \o/ The second case is quite stressful for users, since accessing their configuration wizard for the first time will immediately display a warning that unchecking that option will uninstall a few modules (even though they didn't actually uncheck anything). This commit tries to mitigate this second case. The onchange behaviour needs to adapt to the *actual* state of the module in database - we cannot rely on the module_wrp_workorder field since there is no way to know if it was modified by another onchange, for example. Based on the actual module state, we split the onchange behaviour: - if mrp_workorder *is not* installed, then triggering the group field should be mirrored on the module field (enabling it should install the module, disabling it should cancel the module installation since it must have happened in the same transaction) - if mrp_workorder *is* installed, then disabling the group should *not* uninstall it and enabling the group should, well, enable the group and leave the module selection as it found it
- Loading branch information...
Showing with 8 additions and 1 deletion.