Merge pull request #7199 from RobertSchouten/email_cc_dev
email cc test fixes for frappe/frappe#2441
diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js
index 98f9f6e..0a8d9a1 100755
--- a/erpnext/hr/doctype/employee/employee.js
+++ b/erpnext/hr/doctype/employee/employee.js
@@ -58,6 +58,15 @@
},
update_contact:function(frm){
frm.set_value("prefered_email",frm.fields_dict[frappe.model.scrub(frm.doc.prefered_contact_email)].value)
- }
+ },
+ status: function(frm) {
+ return frm.call({
+ method: "deactivate_sales_person",
+ args: {
+ employee: frm.doc.employee,
+ status: frm.doc.status
+ }
+ });
+ },
});
cur_frm.cscript = new erpnext.hr.EmployeeController({frm: cur_frm});
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index e2e541b..58d1262 100755
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -244,3 +244,9 @@
if holiday_list:
return frappe.get_all('Holiday List', dict(name=holiday_list, holiday_date=date)) and True or False
+@frappe.whitelist()
+def deactivate_sales_person(status = None, employee = None):
+ if status == "Left":
+ sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
+ if sales_person:
+ frappe.db.set_value("Sales Person", sales_person, "enabled", 0)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 94212ec..213199f 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -355,4 +355,5 @@
erpnext.patches.v7_1.update_bom_base_currency
erpnext.patches.v7_0.update_status_of_po_so
erpnext.patches.v7_1.set_budget_against_as_cost_center
-erpnext.patches.v7_1.set_currency_exchange_date
\ No newline at end of file
+erpnext.patches.v7_1.set_currency_exchange_date
+erpnext.patches.v7_1.set_sales_person_status
\ No newline at end of file
diff --git a/erpnext/patches/v7_1/set_sales_person_status.py b/erpnext/patches/v7_1/set_sales_person_status.py
new file mode 100644
index 0000000..929beac
--- /dev/null
+++ b/erpnext/patches/v7_1/set_sales_person_status.py
@@ -0,0 +1,8 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ frappe.reload_doc('setup','doctype','sales_person')
+ frappe.db.sql("""update `tabSales Person` set enabled=1
+ where (employee is null or employee = ''
+ or employee IN (select employee from tabEmployee where status != "Left"))""")
diff --git a/erpnext/projects/doctype/task/task.js b/erpnext/projects/doctype/task/task.js
index c6b6664..7c4eb80 100644
--- a/erpnext/projects/doctype/task/task.js
+++ b/erpnext/projects/doctype/task/task.js
@@ -67,4 +67,12 @@
});
+cur_frm.fields_dict['depends_on'].grid.get_field('task').get_query = function(doc) {
+ if(doc.project) {
+ return {
+ filters: {'project': doc.project}
+ }
+ }
+}
+
cur_frm.add_fetch('task', 'subject', 'subject');
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index c31b0c8..dcbb56b 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -902,13 +902,17 @@
get_terms: function() {
var me = this;
if(this.frm.doc.tc_name) {
- return this.frm.call({
- method: "frappe.client.get_value",
+ return frappe.call({
+ method: 'erpnext.setup.doctype.terms_and_conditions.terms_and_conditions.get_terms_and_conditions',
args: {
- doctype: "Terms and Conditions",
- fieldname: "terms",
- filters: { name: this.frm.doc.tc_name },
+ template_name: this.frm.doc.tc_name,
+ doc: this.frm.doc
},
+ callback: function(r) {
+ if(!r.exc) {
+ me.frm.set_value("terms", r.message);
+ }
+ }
});
}
},
diff --git a/erpnext/setup/doctype/sales_person/sales_person.json b/erpnext/setup/doctype/sales_person/sales_person.json
index 1665ba5..595552e 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.json
+++ b/erpnext/setup/doctype/sales_person/sales_person.json
@@ -29,7 +29,7 @@
"label": "Name and Employee ID",
"length": 0,
"no_copy": 0,
- "options": "fa fa-user",
+ "options": "icon-user",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -190,6 +190,35 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "default": "1",
+ "fieldname": "enabled",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Enabled",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "lft",
"fieldtype": "Int",
"hidden": 1,
@@ -290,7 +319,7 @@
"length": 0,
"no_copy": 0,
"oldfieldtype": "Section Break",
- "options": "fa fa-bullseye",
+ "options": "icon-bullseye",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -366,7 +395,7 @@
],
"hide_heading": 0,
"hide_toolbar": 0,
- "icon": "fa fa-user",
+ "icon": "icon-user",
"idx": 1,
"image_view": 0,
"in_create": 0,
@@ -375,7 +404,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-11-07 05:29:29.299529",
+ "modified": "2016-12-12 18:47:13.924225",
"modified_by": "Administrator",
"module": "Setup",
"name": "Sales Person",
diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json
index ce057c2..bede595 100644
--- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json
+++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.json
@@ -16,6 +16,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 0,
@@ -23,6 +24,7 @@
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Title",
"length": 0,
"no_copy": 1,
@@ -32,6 +34,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
@@ -42,6 +45,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "disabled",
"fieldtype": "Check",
"hidden": 0,
@@ -49,6 +53,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
+ "in_standard_filter": 0,
"label": "Disabled",
"length": 0,
"no_copy": 0,
@@ -57,6 +62,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -67,6 +73,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
+ "columns": 0,
"fieldname": "terms",
"fieldtype": "Text Editor",
"hidden": 0,
@@ -74,6 +81,7 @@
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
+ "in_standard_filter": 0,
"label": "Terms and Conditions",
"length": 0,
"no_copy": 0,
@@ -83,6 +91,36 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "terms_and_conditions_help",
+ "fieldtype": "HTML",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Terms and Conditions Help",
+ "length": 0,
+ "no_copy": 0,
+ "options": "<h4>Standard Terms and Conditions Example</h4>\n\n<pre>Delivery Terms for Order number {{ name }}\n\n-Order Date : {{ transaction_date }} \n-Expected Delivery Date : {{ delivery_date }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your standard reply are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@@ -92,7 +130,7 @@
],
"hide_heading": 0,
"hide_toolbar": 0,
- "icon": "fa fa-legal",
+ "icon": "icon-legal",
"idx": 1,
"image_view": 0,
"in_create": 0,
@@ -101,7 +139,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-07-25 05:24:25.093905",
+ "modified": "2016-12-12 17:31:53.349301",
"modified_by": "Administrator",
"module": "Setup",
"name": "Terms and Conditions",
@@ -117,6 +155,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -137,6 +176,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
@@ -157,6 +197,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
@@ -177,6 +218,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -197,6 +239,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
@@ -217,6 +260,7 @@
"export": 0,
"if_owner": 0,
"import": 0,
+ "is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
@@ -231,5 +275,6 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
+ "sort_order": "ASC",
"track_seen": 0
}
\ No newline at end of file
diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
index 52f5156..d2b68b4 100644
--- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
+++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
@@ -3,8 +3,18 @@
from __future__ import unicode_literals
import frappe
-
+import json
from frappe.model.document import Document
+from frappe.utils.jinja import validate_template
class TermsandConditions(Document):
- pass
\ No newline at end of file
+ def validate(self):
+ validate_template(self.terms)
+
+@frappe.whitelist()
+def get_terms_and_conditions(template_name, doc):
+ if isinstance(doc, basestring):
+ doc = json.loads(doc)
+
+ terms_and_conditions = frappe.get_doc("Terms and Conditions", template_name)
+ return frappe.render_template(terms_and_conditions.terms, doc)
\ No newline at end of file