From d979ed0ea8431d0d0c943fd7895f711210dab2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Hennecart?= Date: Thu, 27 Aug 2020 07:04:30 +0000 Subject: [PATCH] [FIX] crm: fix duplicate lead when mmr is desactived Before when we tried to duplicate a lead without the mrr option active, a traceback was raised. If the MMR option was not activated, then the user was not be able to write on some field because he was lacking the corresponding group. In this case, the recurring_revenue and recurring_plan fields. Now, when copying a lead, we purposefully set those fields to 0/False to avoid a crash if the option is not enabled. task-2325629 closes odoo/odoo#56927 X-original-commit: 1a5cc55dfeb03ad7d4a63a0286d5d33eaca3cbe2 Signed-off-by: Thibault Delavallee (tde) Signed-off-by: awa-odoo --- addons/crm/models/crm_lead.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 129ff3356ee..8de8bb37dd1 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -635,6 +635,9 @@ class Lead(models.Model): # Do not assign to an archived user if not self.user_id.active: default['user_id'] = False + if not self.env.user.has_group('crm.group_use_recurring_revenues'): + default['recurring_revenue'] = 0 + default['recurring_plan'] = False return super(Lead, self.with_context(context)).copy(default=default) @api.model