From 981e96be7c54b6bfe07c5a8d6b399c200d945b3f Mon Sep 17 00:00:00 2001 From: pu-raihan Date: Thu, 17 Oct 2024 10:50:17 +0530 Subject: [PATCH] fix: assigning to new owner and revoking old assignees permissions --- crm/fcrm/doctype/crm_deal/crm_deal.py | 8 +++++--- crm/fcrm/doctype/crm_lead/crm_lead.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.py b/crm/fcrm/doctype/crm_deal/crm_deal.py index 395619b7..4d2251cf 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.py +++ b/crm/fcrm/doctype/crm_deal/crm_deal.py @@ -18,9 +18,11 @@ class CRMDeal(Document): def validate(self): self.set_primary_contact() self.set_primary_email_mobile_no() - if self.deal_owner and not self.is_new(): - self.share_with_agent(self.deal_owner) - self.assign_agent(self.deal_owner) + if not self.is_new(): + curr_owner = frappe.db.get_value(self.doctype,self.name,"deal_owner") + if self.deal_owner and self.deal_owner != curr_owner: + self.share_with_agent(self.deal_owner) + self.assign_agent(self.deal_owner) if self.has_value_changed("status"): add_status_change_log(self) diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.py b/crm/fcrm/doctype/crm_lead/crm_lead.py index 75ca04e0..db448c85 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.py +++ b/crm/fcrm/doctype/crm_lead/crm_lead.py @@ -21,9 +21,11 @@ class CRMLead(Document): self.set_lead_name() self.set_title() self.validate_email() - if self.lead_owner and not self.is_new(): - self.share_with_agent(self.lead_owner) - self.assign_agent(self.lead_owner) + if not self.is_new(): + curr_owner = frappe.db.get_value(self.doctype,self.name,"lead_owner") + if self.lead_owner and self.lead_owner != curr_owner: + self.share_with_agent(self.lead_owner) + self.assign_agent(self.lead_owner) if self.has_value_changed("status"): add_status_change_log(self)