[IMP] crm: make unlink optional in merge_opportunity

closes odoo/odoo#44997

X-original-commit: a8094108a4e469f5bc4a3ba541ede7a61f28d522
Related: odoo/enterprise#8311
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kevin Baptiste
2020-02-10 14:27:58 +00:00
committed by Yannick Tivisse
parent de7a0b3240
commit 32a8b4dce3
+3 -2
View File
@@ -812,7 +812,7 @@ class Lead(models.Model):
self._merge_opportunity_history(opportunities)
self._merge_opportunity_attachments(opportunities)
def merge_opportunity(self, user_id=False, team_id=False):
def merge_opportunity(self, user_id=False, team_id=False, auto_unlink=True):
""" Merge opportunities in one. Different cases of merge:
- merge leads together = 1 new lead
- merge at least 1 opp with anything else (lead or opp) = 1 new opp
@@ -855,7 +855,8 @@ class Lead(models.Model):
# delete tail opportunities
# we use the SUPERUSER to avoid access rights issues because as the user had the rights to see the records it should be safe to do so
opportunities_tail.sudo().unlink()
if auto_unlink:
opportunities_tail.sudo().unlink()
return opportunities_head