Merge pull request #143 from shariquerik/revert-organization-deal-link
fix: remove auto updating deal/org on changing deal/org data
This commit is contained in:
commit
317dcd0e97
@ -18,7 +18,6 @@ class CRMDeal(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.set_primary_contact()
|
self.set_primary_contact()
|
||||||
self.set_primary_email_mobile_no()
|
self.set_primary_email_mobile_no()
|
||||||
self.update_organization()
|
|
||||||
if self.deal_owner and not self.is_new():
|
if self.deal_owner and not self.is_new():
|
||||||
self.share_with_agent(self.deal_owner)
|
self.share_with_agent(self.deal_owner)
|
||||||
self.assign_agent(self.deal_owner)
|
self.assign_agent(self.deal_owner)
|
||||||
@ -69,20 +68,6 @@ class CRMDeal(Document):
|
|||||||
self.mobile_no = ""
|
self.mobile_no = ""
|
||||||
self.phone = ""
|
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):
|
def assign_agent(self, agent):
|
||||||
if not agent:
|
if not agent:
|
||||||
return
|
return
|
||||||
|
|||||||
@ -6,26 +6,6 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CRMOrganization(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
|
@staticmethod
|
||||||
def default_list_data():
|
def default_list_data():
|
||||||
columns = [
|
columns = [
|
||||||
|
|||||||
@ -101,15 +101,13 @@ const rows = computed(() => {
|
|||||||
deals.value.data.rows.forEach((row) => {
|
deals.value.data.rows.forEach((row) => {
|
||||||
_rows[row] = deal[row]
|
_rows[row] = deal[row]
|
||||||
|
|
||||||
let org = getOrganization(deal.organization)
|
|
||||||
|
|
||||||
if (row == 'organization') {
|
if (row == 'organization') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: deal.organization,
|
label: deal.organization,
|
||||||
logo: org?.organization_logo,
|
logo: getOrganization(deal.organization)?.organization_logo,
|
||||||
}
|
}
|
||||||
} else if (row == 'annual_revenue') {
|
} else if (row == 'annual_revenue') {
|
||||||
_rows[row] = formatNumberIntoCurrency(org?.annual_revenue)
|
_rows[row] = formatNumberIntoCurrency(deal.annual_revenue)
|
||||||
} else if (row == 'status') {
|
} else if (row == 'status') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: deal.status,
|
label: deal.status,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user