Skip to content

Commit f5f3b5b

Browse files
authored
Merge pull request #38 from rtCamp/fix/opp-status-overide
fix: update status set logic for opportunity
2 parents a80d7fa + 95d9691 commit f5f3b5b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

next_crm/overrides/opportunity.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
from next_crm.ncrm.doctype.crm_service_level_agreement.utils import get_sla
1212
from next_crm.ncrm.doctype.crm_status_change_log.crm_status_change_log import add_status_change_log
1313

14+
from erpnext.crm.utils import (
15+
copy_comments,
16+
link_communications,
17+
link_open_events,
18+
link_open_tasks,
19+
)
1420

1521
class Opportunity(Opportunity):
1622

@@ -23,14 +29,20 @@ def validate(self):
2329
if not self.is_new() and self.has_value_changed("opportunity_owner") and self.opportunity_owner:
2430
self.share_with_agent(self.opportunity_owner)
2531
self.assign_agent(self.opportunity_owner)
26-
# if self.has_value_changed("status"):
27-
# add_status_change_log(self)
32+
if self.has_value_changed("status"):
33+
add_status_change_log(self)
2834
super().validate()
2935

3036
def after_insert(self):
3137
if self.opportunity_owner:
3238
self.assign_agent(self.opportunity_owner)
33-
super().after_insert()
39+
40+
if self.opportunity_from == "Lead":
41+
link_open_tasks(self.opportunity_from, self.party_name, self)
42+
link_open_events(self.opportunity_from, self.party_name, self)
43+
if frappe.db.get_single_value("CRM Settings", "carry_forward_communication_and_comments"):
44+
copy_comments(self.opportunity_from, self.party_name, self)
45+
link_communications(self.opportunity_from, self.party_name, self)
3446

3547
def before_save(self):
3648
self.apply_sla()

0 commit comments

Comments
 (0)