[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) <tde@openerp.com>
Signed-off-by: awa-odoo <awa-odoo@users.noreply.github.com>
This commit is contained in:
Jérémy Hennecart
2020-09-02 09:32:15 +00:00
parent a7906b282c
commit d979ed0ea8
+3
View File
@@ -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