diff options
| author | David Beguin <dbe@odoo.com> | 2020-09-17 14:20:19 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2020-09-21 17:33:08 +0000 |
| commit | cc4e7f401164acd053864a53372a96873d5d1b77 (patch) | |
| tree | ff1da1af42cb0910bed860a7b7bccda31504b770 /addons/crm/models | |
| parent | 8bb3b09a2abf27011e4920a9dc045fc27e1ec628 (diff) | |
[FIX] crm: fix pls field config parameter and force depends recompute
The method _compute_probability has a dynamic depends, that depends on the
crm.pls_fields config parameter. When installing the DB, the depends is
evaluated. If the config parameter is modified afterwards, the depends is not
re-evaluated as the registry is not rebuilt.
The result is that when modifying the config parameter, if an optional
pls_field's value is modified on a record, the compute won't be triggered, as
that pls_field is not in the compute's depends.
This commit force to re-setup the registry after a modification (or the
creation) of the crm.pls_fields config parameter, in order to force the
depends of the _compute_probability method to be updated.
Task ID: 2341829
closes odoo/odoo#58163
X-original-commit: e95afbedc18d198454c7f66b523c4cafb19a4066
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: David Beguin <dbeguin@users.noreply.github.com>
Diffstat (limited to 'addons/crm/models')
| -rw-r--r-- | addons/crm/models/__init__.py | 1 | ||||
| -rw-r--r-- | addons/crm/models/ir_config_parameter.py | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/addons/crm/models/__init__.py b/addons/crm/models/__init__.py index 9d749786e6d..7b1a7fdcd7a 100644 --- a/addons/crm/models/__init__.py +++ b/addons/crm/models/__init__.py @@ -7,6 +7,7 @@ from . import crm_lead from . import crm_lost_reason from . import crm_stage from . import crm_team +from . import ir_config_parameter from . import res_config_settings from . import res_partner from . import digest diff --git a/addons/crm/models/ir_config_parameter.py b/addons/crm/models/ir_config_parameter.py new file mode 100644 index 00000000000..890120a4974 --- /dev/null +++ b/addons/crm/models/ir_config_parameter.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models + + +class IrConfigParameter(models.Model): + _inherit = 'ir.config_parameter' + + def write(self, vals): + result = super(IrConfigParameter, self).write(vals) + if any(record.key == "crm.pls_fields" for record in self): + self.flush() + self.env.registry.setup_models(self.env.cr) + return result + + @api.model_create_multi + def create(self, vals_list): + records = super(IrConfigParameter, self).create(vals_list) + if any(record.key == "crm.pls_fields" for record in records): + self.flush() + self.env.registry.setup_models(self.env.cr) + return records |
