fix: replaced organization_name (data) with organization (link)

also made other organization field fetch from organization
This commit is contained in:
Shariq Ansari 2023-11-06 15:55:12 +05:30
parent 7bb885b6af
commit c4d8dbad88
3 changed files with 66 additions and 29 deletions

View File

@ -29,9 +29,8 @@
"next_step", "next_step",
"organization_tab", "organization_tab",
"section_break_uixv", "section_break_uixv",
"organization_name", "organization",
"no_of_employees", "no_of_employees",
"organization_logo",
"column_break_dbsv", "column_break_dbsv",
"website", "website",
"job_title", "job_title",
@ -111,10 +110,12 @@
"search_index": 1 "search_index": 1
}, },
{ {
"fetch_from": "organization.website",
"fieldname": "website", "fieldname": "website",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Website", "label": "Website",
"options": "URL" "options": "URL",
"read_only": 1
}, },
{ {
"fieldname": "column_break_sijm", "fieldname": "column_break_sijm",
@ -146,17 +147,15 @@
"fieldname": "no_of_employees", "fieldname": "no_of_employees",
"fieldtype": "Select", "fieldtype": "Select",
"label": "No. of Employees", "label": "No. of Employees",
"options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+" "options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+",
}, "read_only": 1
{
"fieldname": "organization_name",
"fieldtype": "Data",
"label": "Organization Name"
}, },
{ {
"fetch_from": "organization.annual_revenue",
"fieldname": "annual_revenue", "fieldname": "annual_revenue",
"fieldtype": "Currency", "fieldtype": "Currency",
"label": "Annual Revenue" "label": "Annual Revenue",
"read_only": 1
}, },
{ {
"fieldname": "lead_owner", "fieldname": "lead_owner",
@ -171,15 +170,11 @@
"options": "CRM Lead Source" "options": "CRM Lead Source"
}, },
{ {
"fetch_from": "organization.industry",
"fieldname": "industry", "fieldname": "industry",
"fieldtype": "Link", "fieldtype": "Data",
"label": "Industry", "label": "Industry",
"options": "CRM Industry" "read_only": 1
},
{
"fieldname": "organization_logo",
"fieldtype": "Attach Image",
"label": "Organization Logo"
}, },
{ {
"fieldname": "image", "fieldname": "image",
@ -214,9 +209,11 @@
"search_index": 1 "search_index": 1
}, },
{ {
"fetch_from": "organization.job_title",
"fieldname": "job_title", "fieldname": "job_title",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Job Title" "label": "Job Title",
"read_only": 1
}, },
{ {
"fieldname": "organization_tab", "fieldname": "organization_tab",
@ -259,12 +256,18 @@
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 1, "hidden": 1,
"label": "Created as Deal" "label": "Created as Deal"
},
{
"fieldname": "organization",
"fieldtype": "Link",
"label": "Organization",
"options": "CRM Organization"
} }
], ],
"image_field": "image", "image_field": "image",
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-09-27 18:54:18.196159", "modified": "2023-11-06 15:29:56.868755",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "CRM Lead", "name": "CRM Lead",

View File

@ -26,15 +26,17 @@ class CRMLead(Document):
def set_lead_name(self): def set_lead_name(self):
if not self.lead_name: if not self.lead_name:
# Check for leads being created through data import # Check for leads being created through data import
if not self.organization_name and not self.email and not self.flags.ignore_mandatory: if not self.organization and not self.email and not self.flags.ignore_mandatory:
frappe.throw(_("A Lead requires either a person's name or an organization's name")) frappe.throw(_("A Lead requires either a person's name or an organization's name"))
elif self.organization_name: elif self.organization:
self.lead_name = self.organization_name self.lead_name = self.organization
else: elif self.email:
self.lead_name = self.email.split("@")[0] self.lead_name = self.email.split("@")[0]
else:
self.lead_name = "Unnamed Lead"
def set_title(self): def set_title(self):
self.title = self.organization_name or self.lead_name self.title = self.organization or self.lead_name
def validate_email(self): def validate_email(self):
if self.email: if self.email:
@ -106,7 +108,7 @@ class CRMLead(Document):
"salutation": self.salutation, "salutation": self.salutation,
"gender": self.gender, "gender": self.gender,
"designation": self.job_title, "designation": self.job_title,
"company_name": self.organization_name, "company_name": self.organization,
"image": self.image or "", "image": self.image or "",
} }
) )
@ -132,7 +134,7 @@ class CRMLead(Document):
{ "label": 'Modified', "value": 'modified' }, { "label": 'Modified', "value": 'modified' },
{ "label": 'Status', "value": 'status' }, { "label": 'Status', "value": 'status' },
{ "label": 'Lead owner', "value": 'lead_owner' }, { "label": 'Lead owner', "value": 'lead_owner' },
{ "label": 'Organization', "value": 'organization_name' }, { "label": 'Organization', "value": 'organization' },
{ "label": 'Name', "value": 'lead_name' }, { "label": 'Name', "value": 'lead_name' },
{ "label": 'First Name', "value": 'first_name' }, { "label": 'First Name', "value": 'first_name' },
{ "label": 'Last Name', "value": 'last_name' }, { "label": 'Last Name', "value": 'last_name' },

View File

@ -7,8 +7,13 @@
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"organization_name", "organization_name",
"no_of_employees",
"organization_logo",
"column_break_pnpp",
"website", "website",
"organization_logo" "job_title",
"annual_revenue",
"industry"
], ],
"fields": [ "fields": [
{ {
@ -20,18 +25,45 @@
{ {
"fieldname": "website", "fieldname": "website",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Website" "label": "Website",
"options": "URL"
}, },
{ {
"fieldname": "organization_logo", "fieldname": "organization_logo",
"fieldtype": "Attach Image", "fieldtype": "Attach Image",
"label": "Organization Logo" "label": "Organization Logo"
},
{
"fieldname": "no_of_employees",
"fieldtype": "Select",
"label": "No. of Employees",
"options": "1-10\n11-50\n51-200\n201-500\n501-1000\n1000+"
},
{
"fieldname": "column_break_pnpp",
"fieldtype": "Column Break"
},
{
"fieldname": "job_title",
"fieldtype": "Data",
"label": "Job Title"
},
{
"fieldname": "annual_revenue",
"fieldtype": "Currency",
"label": "Annual Revenue"
},
{
"fieldname": "industry",
"fieldtype": "Link",
"label": "Industry",
"options": "CRM Industry"
} }
], ],
"image_field": "organization_logo", "image_field": "organization_logo",
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-11-03 16:25:25.366741", "modified": "2023-11-06 15:28:26.610882",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "CRM Organization", "name": "CRM Organization",