fix: remove auto updating deal/org on changing deal/org data
This commit is contained in:
parent
e04a4c6b4c
commit
9fff23e55a
@ -18,7 +18,6 @@ class CRMDeal(Document):
|
||||
def validate(self):
|
||||
self.set_primary_contact()
|
||||
self.set_primary_email_mobile_no()
|
||||
self.update_organization()
|
||||
if self.deal_owner and not self.is_new():
|
||||
self.share_with_agent(self.deal_owner)
|
||||
self.assign_agent(self.deal_owner)
|
||||
@ -69,20 +68,6 @@ class CRMDeal(Document):
|
||||
self.mobile_no = ""
|
||||
self.phone = ""
|
||||
|
||||
def update_organization(self):
|
||||
if self.organization:
|
||||
if self.has_value_changed("organization"):
|
||||
organization = frappe.get_cached_doc("CRM Organization", self.organization)
|
||||
self.website = organization.website
|
||||
self.territory = organization.territory
|
||||
self.annual_revenue = organization.annual_revenue
|
||||
if self.has_value_changed("website"):
|
||||
frappe.db.set_value("CRM Organization", self.organization, "website", self.website)
|
||||
if self.has_value_changed("territory"):
|
||||
frappe.db.set_value("CRM Organization", self.organization, "territory", self.territory)
|
||||
if self.has_value_changed("annual_revenue"):
|
||||
frappe.db.set_value("CRM Organization", self.organization, "annual_revenue", self.annual_revenue)
|
||||
|
||||
def assign_agent(self, agent):
|
||||
if not agent:
|
||||
return
|
||||
|
||||
@ -6,26 +6,6 @@ from frappe.model.document import Document
|
||||
|
||||
|
||||
class CRMOrganization(Document):
|
||||
def on_update(self):
|
||||
self.update_deal_organization_fields()
|
||||
|
||||
def update_deal_organization_fields(self):
|
||||
if (
|
||||
self.has_value_changed("website")
|
||||
or self.has_value_changed("territory")
|
||||
or self.has_value_changed("annual_revenue")
|
||||
):
|
||||
for deal in frappe.get_all(
|
||||
"CRM Deal",
|
||||
filters={"organization": self.name},
|
||||
):
|
||||
if self.has_value_changed("website"):
|
||||
frappe.db.set_value("CRM Deal", deal.name, "website", self.website)
|
||||
if self.has_value_changed("territory"):
|
||||
frappe.db.set_value("CRM Deal", deal.name, "territory", self.territory)
|
||||
if self.has_value_changed("annual_revenue"):
|
||||
frappe.db.set_value("CRM Deal", deal.name, "annual_revenue", self.annual_revenue)
|
||||
|
||||
@staticmethod
|
||||
def default_list_data():
|
||||
columns = [
|
||||
|
||||
@ -101,15 +101,13 @@ const rows = computed(() => {
|
||||
deals.value.data.rows.forEach((row) => {
|
||||
_rows[row] = deal[row]
|
||||
|
||||
let org = getOrganization(deal.organization)
|
||||
|
||||
if (row == 'organization') {
|
||||
_rows[row] = {
|
||||
label: deal.organization,
|
||||
logo: org?.organization_logo,
|
||||
logo: getOrganization(deal.organization)?.organization_logo,
|
||||
}
|
||||
} else if (row == 'annual_revenue') {
|
||||
_rows[row] = formatNumberIntoCurrency(org?.annual_revenue)
|
||||
_rows[row] = formatNumberIntoCurrency(deal.annual_revenue)
|
||||
} else if (row == 'status') {
|
||||
_rows[row] = {
|
||||
label: deal.status,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user