Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav Naik committed Jan 27, 2017
2 parents 953825c + bc2890e commit 4e86cb9
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 14 deletions.
2 changes: 1 addition & 1 deletion awfis_erpnext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import unicode_literals

__version__ = '1.7.0'
__version__ = '1.7.1'
2 changes: 1 addition & 1 deletion awfis_erpnext/fixtures/custom_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@
"modified": "2016-06-21 12:13:38.919627",
"name": "Lead-awfis_lead_channel",
"no_copy": 0,
"options": "Sales Team\nCall Centre\nCentre Walk-in",
"options": "Sales Team\nCall Centre\nCentre Walk-in\nInbound",
"permlevel": 0,
"precision": "",
"print_hide": 0,
Expand Down
4 changes: 2 additions & 2 deletions awfis_erpnext/fixtures/custom_script.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"docstatus": 0,
"doctype": "Custom Script",
"dt": "Lead",
"modified": "2017-01-25 16:46:06.672859",
"modified": "2017-01-27 11:35:40.486905",
"name": "Lead-Client",
"script": "\nfrappe.ui.form.on(\"Lead\", \"validate\", function(frm){\n if (!isMobileNoValid(frm.doc.mobile_no)) {\n flashMessage();\n validated = false;\n }\n});\n\nfunction isMobileNoValid(mobno) {\n return (mobno.length == 10);\n}\n\nfunction flashMessage() {\n msgprint(__(\"Entered Mobile No. is either incomplete or invalid. <br /> Tip: Add it without the +0 or +91 at the beginning.\", \"Invalid Mobile No\"));\n}\n\nfrappe.ui.form.on(\"Lead\", \"onload\", function(frm) {\n frm.set_query(\"channel_partner\", function() {\n \treturn {\n\t \"filters\": {\n \"partner_type\": frm.doc.source\n }\n };\n });\n frm.set_query( \"awfis_lead_territory\", function() {\n \treturn {\n\t \"filters\": {\n \"is_group\": \"No\"\n }\n };\n });\n});\n\n//Set FirstName and LastName\nfrappe.ui.form.on(\"Lead\", \"first_name\", function(frm){\n frm.set_value(\"lead_name\", buildName(frm.doc.first_name, frm.doc.last_name));\n});\n\nfrappe.ui.form.on(\"Lead\", \"last_name\", function(frm){\n frm.set_value(\"lead_name\", buildName(frm.doc.first_name, frm.doc.last_name));\n});\n\n//Lead Name cannot be hidden via Customize Form. Hide using script.\nfrappe.ui.form.on(\"Lead\", \"refresh\", function(frm) {\n frm.toggle_display(\"lead_name\", false);\n frm.toggle_display(\"lead_name\", false);\n \n //Set sources by channel. \n var sources_by_channel = { \n \"Sales Team\" : [\"Referral\", \"Marketing\", \"Broker\"], \n \"Centre Walk-in\": [\"Outdoor\", \"Online\", \"Referral\", \"Marketing\"],\n \"Call Centre\": [\"Outdoor\", \"Online\", \"Referral\", \"Marketing\"]\n } \n\n var campaigns_by_sub_source = {\n \"Events\" : [\"Internal\", \"External\"],\n \"Social Media\": [\"Facebook\", \"Twitter\", \"Instagram\", \"Youtube\", \"Google\", \"Linkedin\"],\n \"Online Listings\": [\"99Acres\", \"Magic Bricks\", \"CoWorkable\", \"Work Spot\", \"Space Hiring\"],\n \"Advertising\": [\"TV\", \"Radio\", \"Theatre\", \"Print\"],\n \"Friend/Colleague\": [\"Word of Mouth\"] \n }\n\n \n\n cur_frm.set_query(\"source\", function() {\n return {\n \"filters\": [\n [\"Lead Source\", \"name\", \"in\", sources_by_channel[cur_frm.doc.awfis_lead_channel]]\n ]\n }\n });\n\n cur_frm.set_query(\"awfis_lead_sub_source\", function() {\n return {\n \"filters\": [\n [\"Lead Source\", \"awfis_lead_source_parent\", \"=\", cur_frm.doc.source]\n ]\n }\n });\n\n cur_frm.set_query(\"campaign_name\", function() {\n if ((cur_frm.doc.awfis_lead_channel == \"Sales Team\") && (cur_frm.doc.source == \"Marketing\")) {\n return {\n \"filters\": [\n [\"Campaign\", \"name\", \"in\", [\"Email\", \"Cold Calling\"]]\n ]\n }\n } else {\n return {\n \"filters\": [\n [\"Campaign\", \"name\", \"in\", campaigns_by_sub_source[cur_frm.doc.awfis_lead_sub_source] || []]\n ]\n }\n }\n }); \n\n});\n\n//Set value of Mobile No when Awfis Mobile No is entered.\nfrappe.ui.form.on(\"Lead\", \"awfis_mobile_no\", function(frm) {\n frm.set_value(\"mobile_no\", frm.doc.awfis_mobile_no);\n});\n\n//Set value of Mobile No when Awfis Mobile No is entered.\nfrappe.ui.form.on(\"Lead\", \"awfis_company_website\", function(frm) {\n frm.set_value(\"website\", frm.doc.awfis_company_website);\n});\n\n//Set value of Mobile No when Awfis Mobile No is entered.\nfrappe.ui.form.on(\"Lead\", \"awfis_email_id\", function(frm) {\n frm.set_value(\"email_id\", frm.doc.awfis_email_id);\n});\n\n//Set value of Territory when Awfis Lead Territory is set.\nfrappe.ui.form.on(\"Lead\", \"awfis_lead_territory\", function(frm) {\n frm.set_value(\"territory\", frm.doc.awfis_lead_territory);\n});\n\n//Helpers\nfunction buildName(fname, lname) {\n\tif (!lname) {\n\t\treturn fname;\n\t} else if (!fname) {\n\t\treturn lname;\n\t} else {\n\t\treturn fname + ' ' + lname;\n\t}\n}\n\nfrappe.ui.form.on(\"Lead Awfis Space\", \"space_type\", function(frm, cdt, cdn) {\n var space = locals[cdt][cdn];\n if (space.space_type == \"Desk-Fixed\" || space.space_type == \"Desk-Flexi\") {\n space.capacity = 1;\n set_capacity_property_readonly(1);\n } else {\n space.capacity = \"\";\n set_capacity_property_readonly(0);\n }\n refresh_field(\"awfis_spaces\"); \n});\n\nfunction set_capacity_property_readonly(state) {\n var df = frappe.meta.get_docfield(\"Lead Awfis Space\",\"capacity\", cur_frm.doc.name);\n df.read_only = state;\n}\n\nfrappe.ui.form.on(\"Lead\", \"source\", function(frm) {\n if (frm.doc.source === \"IPC\" || frm.doc.source === \"Broker\" ){\n frm.set_value(\"type\", \"Channel Partner\");\n } else{\n frm.set_value(\"type\", \"\");\n }\n set_visibility_by_channel();\n});\n\nfrappe.ui.form.on(\"Lead\", \"awfis_lead_channel\", function(frm) {\n cur_frm.set_value(\"source\", \"\");\n cur_frm.set_value(\"awfis_lead_sub_source\", \"\");\n cur_frm.set_value(\"campaign_name\", \"\");\n set_visibility_by_channel();\n});\n\nfrappe.ui.form.on(\"Lead\", \"awfis_lead_sub_source\", function(frm) {\n cur_frm.set_value(\"campaign_name\", \"\");\n set_visibility_by_channel();\n});\n\nfunction set_visibility_by_channel() {\n \n \n\n //Set visibility\n var sub_source_hidden = (cur_frm.doc.awfis_lead_channel == \"Sales Team\")\n && ((cur_frm.doc.source == \"Marketing\") || (cur_frm.doc.source == \"Broker\")); \n\n console.log(\"Source Hidden\", sub_source_hidden);\n\n cur_frm.set_df_property(\"awfis_lead_sub_source\", \"hidden\", sub_source_hidden);\n\n //Hidden when sub_source is not among these or when source is \n \n if (cur_frm.doc.awfis_lead_channel == \"Sales Team\" && cur_frm.doc.source == \"Marketing\") {\n cur_frm.set_df_property(\"campaign_name\", \"hidden\", 1);\n console.log(\"Checking channel,source, Hidden 1\");\n } else if ([\"Events\", \"Social Media\", \"Online Listings\", \"Advertising\", \"Friend/Colleague\"].indexOf(cur_frm.doc.awfis_lead_sub_source) == -1) {\n cur_frm.set_df_property(\"campaign_name\", \"hidden\", 1);\n console.log(\"Checking Subsource, Hidden 1\", cur_frm.doc.awfis_lead_sub_source);\n } else {\n cur_frm.set_df_property(\"campaign_name\", \"hidden\", 0); \n console.log(\"Hidden 0\")\n }\n\n}",
"script": "\nfrappe.ui.form.on(\"Lead\", \"validate\", function(frm){\n if (!isMobileNoValid(frm.doc.mobile_no)) {\n flashMessage();\n validated = false;\n }\n});\n\nfunction isMobileNoValid(mobno) {\n return (mobno.length == 10);\n}\n\nfunction flashMessage() {\n msgprint(__(\"Entered Mobile No. is either incomplete or invalid. <br /> Tip: Add it without the +0 or +91 at the beginning.\", \"Invalid Mobile No\"));\n}\n\nfrappe.ui.form.on(\"Lead\", \"onload\", function(frm) {\n frm.set_query(\"channel_partner\", function() {\n return {\n \"filters\": {\n \"partner_type\": frm.doc.source\n }\n };\n });\n frm.set_query( \"awfis_lead_territory\", function() {\n return {\n \"filters\": {\n \"is_group\": \"No\"\n }\n };\n });\n});\n\n//Set FirstName and LastName\nfrappe.ui.form.on(\"Lead\", \"first_name\", function(frm){\n frm.set_value(\"lead_name\", buildName(frm.doc.first_name, frm.doc.last_name));\n});\n\nfrappe.ui.form.on(\"Lead\", \"last_name\", function(frm){\n frm.set_value(\"lead_name\", buildName(frm.doc.first_name, frm.doc.last_name));\n});\n\n//Lead Name cannot be hidden via Customize Form. Hide using script.\nfrappe.ui.form.on(\"Lead\", \"refresh\", function(frm) {\n frm.toggle_display(\"lead_name\", false);\n frm.toggle_display(\"lead_name\", false);\n \n //Set sources by channel. \n var sources_by_channel = { \n \"Sales Team\" : [\"Referral\", \"Marketing\", \"Broker\"], \n \"Centre Walk-in\": [\"Outdoor\", \"Online\", \"Referral\", \"Marketing\"],\n \"Call Centre\": [\"Outdoor\", \"Online\", \"Referral\", \"Marketing\", \"Returning Customer\"]\n } \n\n var campaigns_by_sub_source = {\n \"Events\" : [\"Internal\", \"External\"],\n \"Social Media\": [\"Facebook\", \"Twitter\", \"Instagram\", \"Youtube\", \"Google\", \"Linkedin\"],\n \"Online Listing\": [\"99Acres\", \"Magic Bricks\", \"CoWorkable\", \"Work Spot\", \"Space Hiring\"],\n \"Advertising\": [\"TV\", \"Radio\", \"Theatre\", \"Print\"],\n \"Friend/Colleague\": [\"Word of Mouth\"] \n }\n\n cur_frm.set_query(\"source\", function() {\n return {\n \"filters\": [\n [\"Lead Source\", \"name\", \"in\", sources_by_channel[cur_frm.doc.awfis_lead_channel]]\n ]\n }\n });\n\n cur_frm.set_query(\"awfis_lead_sub_source\", function() {\n return {\n \"filters\": [\n [\"Lead Source\", \"awfis_lead_source_parent\", \"=\", cur_frm.doc.source]\n ]\n }\n });\n\n cur_frm.set_query(\"campaign_name\", function() {\n if ((cur_frm.doc.awfis_lead_channel == \"Sales Team\") && (cur_frm.doc.source == \"Marketing\")) {\n return {\n \"filters\": [\n [\"Campaign\", \"name\", \"in\", [\"Email\", \"Cold Calling\"]]\n ]\n }\n } else {\n return {\n \"filters\": [\n [\"Campaign\", \"name\", \"in\", campaigns_by_sub_source[cur_frm.doc.awfis_lead_sub_source] || []]\n ]\n }\n }\n }); \n set_visibility_by_channel();\n});\n\n//Set value of Mobile No when Awfis Mobile No is entered.\nfrappe.ui.form.on(\"Lead\", \"awfis_mobile_no\", function(frm) {\n frm.set_value(\"mobile_no\", frm.doc.awfis_mobile_no);\n});\n\n//Set value of Mobile No when Awfis Mobile No is entered.\nfrappe.ui.form.on(\"Lead\", \"awfis_company_website\", function(frm) {\n frm.set_value(\"website\", frm.doc.awfis_company_website);\n});\n\n//Set value of Mobile No when Awfis Mobile No is entered.\nfrappe.ui.form.on(\"Lead\", \"awfis_email_id\", function(frm) {\n frm.set_value(\"email_id\", frm.doc.awfis_email_id);\n});\n\n//Set value of Territory when Awfis Lead Territory is set.\nfrappe.ui.form.on(\"Lead\", \"awfis_lead_territory\", function(frm) {\n frm.set_value(\"territory\", frm.doc.awfis_lead_territory);\n});\n\n//Helpers\nfunction buildName(fname, lname) {\n if (!lname) {\n return fname;\n } else if (!fname) {\n return lname;\n } else {\n return fname + ' ' + lname;\n }\n}\n\nfrappe.ui.form.on(\"Lead Awfis Space\", \"space_type\", function(frm, cdt, cdn) {\n var space = locals[cdt][cdn];\n if (space.space_type == \"Desk-Fixed\" || space.space_type == \"Desk-Flexi\") {\n space.capacity = 1;\n set_capacity_property_readonly(1);\n } else {\n space.capacity = \"\";\n set_capacity_property_readonly(0);\n }\n refresh_field(\"awfis_spaces\"); \n});\n\nfunction set_capacity_property_readonly(state) {\n var df = frappe.meta.get_docfield(\"Lead Awfis Space\",\"capacity\", cur_frm.doc.name);\n df.read_only = state;\n}\n\nfrappe.ui.form.on(\"Lead\", \"source\", function(frm) {\n if (frm.doc.source === \"IPC\" || frm.doc.source === \"Broker\" ){\n frm.set_value(\"type\", \"Channel Partner\");\n } else{\n frm.set_value(\"type\", \"\");\n }\n cur_frm.set_value(\"awfis_lead_sub_source\", \"\");\n cur_frm.set_value(\"campaign_name\", \"\");\n set_visibility_by_channel();\n});\n\nfrappe.ui.form.on(\"Lead\", \"awfis_lead_channel\", function(frm) {\n cur_frm.set_value(\"source\", \"\");\n cur_frm.set_value(\"awfis_lead_sub_source\", \"\");\n cur_frm.set_value(\"campaign_name\", \"\");\n set_visibility_by_channel();\n});\n\nfrappe.ui.form.on(\"Lead\", \"awfis_lead_sub_source\", function(frm) {\n cur_frm.set_value(\"campaign_name\", \"\");\n set_visibility_by_channel();\n});\n\nfunction set_visibility_by_channel() {\n //Set visibility of sub source\n if (cur_frm.doc.awfis_lead_channel == \"Sales Team\") {\n cur_frm.set_df_property(\"awfis_lead_sub_source\", \"hidden\", (cur_frm.doc.source != \"Referral\"));\n } else if (cur_frm.doc.awfis_lead_channel == \"Call Centre\") {\n cur_frm.set_df_property(\"awfis_lead_sub_source\", \"hidden\", (cur_frm.doc.source == \"Returning Customer\"));\n } else {\n cur_frm.set_df_property(\"awfis_lead_sub_source\", \"hidden\", 0);\n }\n\n //Set visibility of campaign\n if (cur_frm.doc.awfis_lead_channel == \"Sales Team\") {\n cur_frm.set_df_property(\"campaign_name\", \"hidden\", (cur_frm.doc.source != \"Marketing\")); \n } else if ([\"Events\", \"Social Media\", \"Online Listing\", \"Advertising\", \"Friend/Colleague\"].indexOf(cur_frm.doc.awfis_lead_sub_source) == -1) {\n cur_frm.set_df_property(\"campaign_name\", \"hidden\", 1);\n } else {\n cur_frm.set_df_property(\"campaign_name\", \"hidden\", 0);\n }\n}",
"script_type": "Client"
},
{
Expand Down
126 changes: 117 additions & 9 deletions awfis_erpnext/fixtures/lead_source.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[
{
"awfis_lead_source_parent": "Marketing",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 17:41:56.046301",
"name": "Cold Calling",
"source_name": "Cold Calling"
},
{
"awfis_lead_source_parent": "Marketing",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 17:42:00.386412",
"name": "E-mail marketing",
"source_name": "E-mail marketing"
},
{
"awfis_lead_source_parent": null,
"details": null,
Expand Down Expand Up @@ -35,15 +53,6 @@
"name": "Referral",
"source_name": "Referral"
},
{
"awfis_lead_source_parent": null,
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:00:21.879391",
"name": "Marketing",
"source_name": "Marketing"
},
{
"awfis_lead_source_parent": null,
"details": null,
Expand All @@ -61,5 +70,104 @@
"modified": "2017-01-25 11:04:59.001621",
"name": "Outdoor",
"source_name": "Outdoor"
},
{
"awfis_lead_source_parent": "Outdoor",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:54:05.503386",
"name": "Hoarding",
"source_name": "Hoarding"
},
{
"awfis_lead_source_parent": "Outdoor",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:55:32.611889",
"name": "Signage",
"source_name": "Signage"
},
{
"awfis_lead_source_parent": "Outdoor",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:53:54.967517",
"name": "Events",
"source_name": "Events"
},
{
"awfis_lead_source_parent": "Online",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:40:09.303917",
"name": "Website",
"source_name": "Website"
},
{
"awfis_lead_source_parent": "Online",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:39:59.314698",
"name": "Google Search",
"source_name": "Google Search"
},
{
"awfis_lead_source_parent": "Referral",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:36:49.190658",
"name": "Client",
"source_name": "Client"
},
{
"awfis_lead_source_parent": "Referral",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:36:40.454933",
"name": "Employee",
"source_name": "Employee"
},
{
"awfis_lead_source_parent": "Referral",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 11:36:26.975366",
"name": "Friend/Colleague",
"source_name": "Friend/Colleague"
},
{
"awfis_lead_source_parent": "Marketing",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 17:41:50.018562",
"name": "Advertising",
"source_name": "Advertising"
},
{
"awfis_lead_source_parent": null,
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-25 17:41:35.302629",
"name": "Marketing",
"source_name": "Marketing"
},
{
"awfis_lead_source_parent": "",
"details": null,
"docstatus": 0,
"doctype": "Lead Source",
"modified": "2017-01-27 11:27:51.684013",
"name": "Returning Customer",
"source_name": "Returning Customer"
}
]
4 changes: 3 additions & 1 deletion awfis_erpnext/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,6 @@
{"dt":"Print Format", "filters": [["name", "in", ["Awfis Purchase Order"]]]},
{"dt":"Lead Source", "filters":[["name", "in", ["IPC",
"Outdoor hoardings/ Banners/ signage outside Awfis centres", "Customer",
"Outdoor", "Online", "Marketing", "Referral"]]]}]
"Outdoor", "Online", "Marketing", "Referral", "Signage", "Hoarding", "Events", "Cold Calling",
"Website", "Friend/Colleague", "Advertising", "Client", "Google Search",
"Employee", "E-mail marketing", "Returning Customer"]]]}]

0 comments on commit 4e86cb9

Please sign in to comment.