瀏覽代碼

[enhance] moved contact to frappe 💥

version-14
Rushabh Mehta 8 年之前
父節點
當前提交
d6c3c9a8e7
共有 31 個文件被更改,包括 3726 次插入1479 次删除
  1. +1351
    -1351
      frappe/core/doctype/communication/communication.json
  2. +0
    -0
      frappe/core/doctype/dynamic_link/__init__.py
  3. +97
    -0
      frappe/core/doctype/dynamic_link/dynamic_link.json
  4. +13
    -0
      frappe/core/doctype/dynamic_link/dynamic_link.py
  5. +45
    -17
      frappe/core/doctype/user/user.json
  6. +4
    -3
      frappe/core/doctype/user_email/user_email.json
  7. +24
    -0
      frappe/desk/reportview.py
  8. +0
    -0
      frappe/email/doctype/contact/__init__.py
  9. +41
    -0
      frappe/email/doctype/contact/contact.js
  10. +805
    -0
      frappe/email/doctype/contact/contact.json
  11. +130
    -0
      frappe/email/doctype/contact/contact.py
  12. +12
    -0
      frappe/email/doctype/contact/test_contact.py
  13. +22
    -0
      frappe/email/doctype/contact/test_records.json
  14. +19
    -19
      frappe/email/page/email_inbox/email_inbox.js
  15. +0
    -0
      frappe/geo/doctype/address/__init__.py
  16. +25
    -0
      frappe/geo/doctype/address/address.js
  17. +651
    -0
      frappe/geo/doctype/address/address.json
  18. +203
    -0
      frappe/geo/doctype/address/address.py
  19. +18
    -0
      frappe/geo/doctype/address/test_address.py
  20. +15
    -0
      frappe/geo/doctype/address/test_records.json
  21. +0
    -0
      frappe/geo/doctype/address_template/__init__.py
  22. +16
    -0
      frappe/geo/doctype/address_template/address_template.js
  23. +148
    -0
      frappe/geo/doctype/address_template/address_template.json
  24. +43
    -0
      frappe/geo/doctype/address_template/address_template.py
  25. +24
    -0
      frappe/geo/doctype/address_template/test_address_template.py
  26. +13
    -0
      frappe/geo/doctype/address_template/test_records.json
  27. +4
    -0
      frappe/hooks.py
  28. +0
    -4
      frappe/patches.txt
  29. +0
    -12
      frappe/patches/v7_1/fix_email_sender.py
  30. +0
    -72
      frappe/patches/v7_2/match_emails_to_contacts.py
  31. +3
    -1
      frappe/public/js/legacy/clientscriptAPI.js

+ 1351
- 1351
frappe/core/doctype/communication/communication.json
文件差異過大導致無法顯示
查看文件


+ 0
- 0
frappe/core/doctype/dynamic_link/__init__.py 查看文件


+ 97
- 0
frappe/core/doctype/dynamic_link/dynamic_link.json 查看文件

@@ -0,0 +1,97 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2017-01-13 04:55:18.835023",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "link_doctype",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Link DocType",
"length": 0,
"no_copy": 0,
"options": "DocType",
"permlevel": 0,
"precision": "",
"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,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "link_name",
"fieldtype": "Dynamic Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Link Name",
"length": 0,
"no_copy": 0,
"options": "link_doctype",
"permlevel": 0,
"precision": "",
"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,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-01-13 04:55:18.835023",
"modified_by": "Administrator",
"module": "Core",
"name": "Dynamic Link",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0
}

+ 13
- 0
frappe/core/doctype/dynamic_link/dynamic_link.py 查看文件

@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document

class DynamicLink(Document):
pass

def on_doctype_update():
frappe.db.add_index("Dynamic Link", ["link_doctype", "link_name"])

+ 45
- 17
frappe/core/doctype/user/user.json 查看文件

@@ -837,20 +837,19 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "users will have user permissions created for each account assigned",
"fieldname": "user_emails",
"fieldtype": "Table",
"default": "1",
"fieldname": "thread_notify",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "User Emails",
"label": "Send Notifications for Transactions I Follow",
"length": 0,
"no_copy": 0,
"options": "User Email",
"permlevel": 1,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
@@ -867,16 +866,42 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "1",
"fieldname": "thread_notify",
"fieldtype": "Check",
"fieldname": "email_signature",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Send Notifications for Transactions I Follow",
"label": "Email Signature",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"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": 1,
"columns": 0,
"fieldname": "email_inbox",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Inbox",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -896,18 +921,21 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "email_signature",
"fieldtype": "Small Text",
"description": "",
"fieldname": "user_emails",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Signature",
"label": "User Emails",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"no_copy": 0,
"options": "User Email",
"permlevel": 1,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
@@ -1094,7 +1122,7 @@
"collapsible": 1,
"columns": 0,
"default": "",
"description": "Uncheck modules to hide from user's desktop",
"description": "",
"fieldname": "modules_access",
"fieldtype": "Section Break",
"hidden": 0,
@@ -1785,7 +1813,7 @@
"istable": 0,
"max_attachments": 5,
"menu_index": 0,
"modified": "2017-01-10 08:47:42.781330",
"modified": "2017-01-13 07:10:40.266109",
"modified_by": "Administrator",
"module": "Core",
"name": "User",


+ 4
- 3
frappe/core/doctype/user_email/user_email.json 查看文件

@@ -8,7 +8,7 @@
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 0,
"editable_grid": 1,
"fields": [
{
"allow_on_submit": 0,
@@ -23,7 +23,7 @@
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "email account",
"label": "Email Account",
"length": 0,
"no_copy": 0,
"options": "Email Account",
@@ -108,7 +108,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-01-05 14:52:38.744801",
"modified": "2017-01-13 07:07:40.049130",
"modified_by": "Administrator",
"module": "Core",
"name": "User Email",
@@ -120,5 +120,6 @@
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

+ 24
- 0
frappe/desk/reportview.py 查看文件

@@ -282,3 +282,27 @@ def build_match_conditions(doctype, as_condition=True):
return match_conditions.replace("%", "%%")
else:
return match_conditions

def get_filters_cond(doctype, filters, conditions):
if filters:
flt = filters
if isinstance(filters, dict):
filters = filters.items()
flt = []
for f in filters:
if isinstance(f[1], basestring) and f[1][0] == '!':
flt.append([doctype, f[0], '!=', f[1][1:]])
else:
value = frappe.db.escape(f[1]) if isinstance(f[1], basestring) else f[1]
flt.append([doctype, f[0], '=', value])

query = DatabaseQuery(doctype)
query.filters = flt
query.conditions = conditions
query.build_filter_conditions(flt, conditions)

cond = ' and ' + ' and '.join(query.conditions)
else:
cond = ''
return cond


+ 0
- 0
frappe/email/doctype/contact/__init__.py 查看文件


+ 41
- 0
frappe/email/doctype/contact/contact.js 查看文件

@@ -0,0 +1,41 @@
// Copyright (c) 2016, Frappe Technologies and contributors
// For license information, please see license.txt


cur_frm.email_field = "email_id";
frappe.ui.form.on("Contact", {
refresh: function(frm) {
if(frm.doc.__islocal) {
var last_route = frappe.route_history.slice(-2, -1)[0];
if(frappe.contact_link && frappe.contact_link.doc
&& frappe.contact_link.doc.name==last_route[2]) {
frm.add_child('links', {
link_doctype: frappe.contact_link.doctype,
link_name: frappe.contact_link.doc[frappe.contact_link.fieldname]
});
}
}

if(!frm.doc.user && !frm.is_new() && frm.perm[0].write) {
frm.add_custom_button(__("Invite as User"), function() {
frappe.call({
method: "erpnext.utilities.doctype.contact.contact.invite_user",
args: {
contact: frm.doc.name
},
callback: function(r) {
frm.set_value("user", r.message);
}
});
});
}
},
validate: function(frm) {
// clear linked customer / supplier / sales partner on saving...
if(frm.doc.links) {
frm.doc.links.forEach(function(d) {
frappe.model.remove_from_locals(d.link_doctype, d.link_name);
});
}
}
});

+ 805
- 0
frappe/email/doctype/contact/contact.json 查看文件

@@ -0,0 +1,805 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 1,
"beta": 0,
"creation": "2013-01-10 16:34:32",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "contact_section",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "",
"length": 0,
"no_copy": 0,
"options": "fa fa-user",
"permlevel": 0,
"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": "first_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "First Name",
"length": 0,
"no_copy": 0,
"oldfieldname": "first_name",
"oldfieldtype": "Data",
"permlevel": 0,
"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,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "last_name",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Last Name",
"length": 0,
"no_copy": 0,
"oldfieldname": "last_name",
"oldfieldtype": "Data",
"permlevel": 0,
"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": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "email_id",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Address",
"length": 0,
"no_copy": 0,
"oldfieldname": "email_id",
"oldfieldtype": "Data",
"options": "Email",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "user",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "User Id",
"length": 0,
"no_copy": 0,
"options": "User",
"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": "cb00",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"default": "Passive",
"fieldname": "status",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Status",
"length": 0,
"no_copy": 0,
"options": "Passive\nOpen\nReplied",
"permlevel": 0,
"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": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "phone",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Phone",
"length": 0,
"no_copy": 0,
"oldfieldname": "contact_no",
"oldfieldtype": "Data",
"permlevel": 0,
"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": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "mobile_no",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Mobile No",
"length": 0,
"no_copy": 0,
"oldfieldname": "mobile_no",
"oldfieldtype": "Data",
"permlevel": 0,
"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": "image",
"fieldtype": "Attach Image",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Image",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"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": "contact_details",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Reference",
"length": 0,
"no_copy": 0,
"options": "fa fa-pushpin",
"permlevel": 0,
"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,
"default": "0",
"depends_on": "",
"fieldname": "is_primary_contact",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Primary Contact",
"length": 0,
"no_copy": 0,
"oldfieldname": "is_primary_contact",
"oldfieldtype": "Select",
"permlevel": 0,
"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": "links",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Links",
"length": 0,
"no_copy": 0,
"options": "Dynamic Link",
"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": "more_info",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "More Information",
"length": 0,
"no_copy": 0,
"options": "fa fa-file-text",
"permlevel": 0,
"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,
"description": "",
"fieldname": "department",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Department",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"description": "",
"fieldname": "designation",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Designation",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "column_break_17",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"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": "unsubscribed",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Unsubscribed",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-user",
"idx": 1,
"image_field": "image",
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-01-13 06:59:06.417300",
"modified_by": "Administrator",
"module": "Email",
"name": "Contact",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Master Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Master Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Maintenance Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Maintenance User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"match": "",
"permlevel": 1,
"print": 0,
"read": 1,
"report": 1,
"role": "All",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",
"track_changes": 0,
"track_seen": 0
}

+ 130
- 0
frappe/email/doctype/contact/contact.py 查看文件

@@ -0,0 +1,130 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, has_gravatar
from frappe import _
from frappe.model.document import Document

class Contact(Document):
def autoname(self):
# concat first and last name
self.name = " ".join(filter(None,
[cstr(self.get(f)).strip() for f in ["first_name", "last_name"]]))

# concat party name if reqd
for link in self.links:
self.name = self.name + '-' + link.link_name.strip()
break

def validate(self):
self.set_user()
if self.email_id:
self.image = has_gravatar(self.email_id)

def set_user(self):
if not self.user and self.email_id:
self.user = frappe.db.get_value("User", {"email": self.email_id})

def on_trash(self):
frappe.db.sql("""update `tabIssue` set contact='' where contact=%s""",
self.name)

def has_common_link(self, doc):
reference_links = [(link.link_doctype, link.link_name) for link in doc.links]
for link in self.links:
if (link.link_doctype, link.link_name) in reference_links:
return True


def get_default_contact(doctype, name):
'''Returns default contact for the given doctype, name'''
out = frappe.db.sql('''select contact.name
from
tabContact contact, `tabDynamic Link` dl
where
dl.parent = contact.name and
dl.link_doctype=%s and
dl.link_name=%s and
dl.parenttype = "Contact"
order by
contact.is_primary_contact desc, name
limit 1''', (doctype, name), debug=1)

print out
return out and out[0][0] or None

@frappe.whitelist()
def invite_user(contact):
contact = frappe.get_doc("Contact", contact)

if not contact.email_id:
frappe.throw(_("Please set Email Address"))

if contact.has_permission("write"):
user = frappe.get_doc({
"doctype": "User",
"first_name": contact.first_name,
"last_name": contact.last_name,
"email": contact.email_id,
"user_type": "Website User",
"send_welcome_email": 1
}).insert(ignore_permissions = True)

return user.name

@frappe.whitelist()
def get_contact_details(contact):
contact = frappe.get_doc("Contact", contact)
out = {
"contact_person": contact.get("name"),
"contact_display": " ".join(filter(None,
[contact.get("first_name"), contact.get("last_name")])),
"contact_email": contact.get("email_id"),
"contact_mobile": contact.get("mobile_no"),
"contact_phone": contact.get("phone"),
"contact_designation": contact.get("designation"),
"contact_department": contact.get("department")
}
return out

def update_contact(doc, method):
'''Update contact when user is updated, if contact is found. Called via hooks'''
contact_name = frappe.db.get_value("Contact", {"email_id": doc.name})
if contact_name:
contact = frappe.get_doc("Contact", contact_name)
for key in ("first_name", "last_name", "phone"):
if doc.get(key):
contact.set(key, doc.get(key))
contact.flags.ignore_mandatory = True
contact.save(ignore_permissions=True)

def contact_query(doctype, txt, searchfield, start, page_len, filters):
from frappe.desk.reportview import get_match_cond

return frappe.db.sql("""select
contact.name, contact.first_name, contact.last_name
from
tabContact as contact, `tabDynamic Link` as dl
where
dl.parent = contact.name and
dl.parenttype = 'Contact' and
dl.link_doctype = %(link_doctype)s and
dl.link_name = %(link_name)s and
contact.`{key}` like %(txt)s
{mcond}
order by
if(locate(%(_txt)s, contact.name), locate(%(_txt)s, contact.name), 99999),
contact.idx desc, contact.name
limit %(start)s, %(page_len)s """.format(
mcond=get_match_cond(doctype),
key=frappe.db.escape(searchfield)),
{
'txt': "%%%s%%" % frappe.db.escape(txt),
'_txt': txt.replace("%", ""),
'start': start,
'page_len': page_len,
'link_doctype': filters.get('link_doctype'),
'link_name': filters.get('link_name')
})

+ 12
- 0
frappe/email/doctype/contact/test_contact.py 查看文件

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest

test_records = frappe.get_test_records('Contact')

class TestContact(unittest.TestCase):
pass

+ 22
- 0
frappe/email/doctype/contact/test_records.json 查看文件

@@ -0,0 +1,22 @@
[
{
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"doctype": "Contact",
"email_id": "test_contact_customer@example.com",
"first_name": "_Test Contact For _Test Customer",
"is_primary_contact": 1,
"phone": "+91 0000000000",
"status": "Open"
},
{
"doctype": "Contact",
"email_id": "test_contact_supplier@example.com",
"first_name": "_Test Contact For _Test Supplier",
"is_primary_contact": 1,
"phone": "+91 0000000000",
"status": "Open",
"supplier": "_Test Supplier",
"supplier_name": "_Test Supplier"
}
]

+ 19
- 19
frappe/email/page/email_inbox/email_inbox.js 查看文件

@@ -71,16 +71,16 @@ frappe.Inbox = frappe.ui.Listing.extend({
}
me.fresh = false
});
}else{
alert("No Email Account assigned to you contact your System administrator");
if (frappe.session.user==="Administrator")
{
frappe.set_route("List", "User");
}
else
{
window.history.back();
}
} else {
frappe.msgprint(__("No Email Account assigned to you. Please contact your System Administrator"));
setTimeout(function() {
if (frappe.session.user==="Administrator") {
frappe.set_route("List", "User");
} else {
frappe.set_route('');
}
}, 3000);
}
},
refresh:function(){
@@ -259,7 +259,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
"fieldname":"newcontact",
"description": __('Create new Contact for a Customer, Supplier, User or Organisation to Match "') + row.sender + __('" Against')
}
];
if (!nomatch) {
fields.push({
@@ -283,7 +283,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
frappe.route_titles["create_contact"] = 1;
var name_split = row.sender_full_name?row.sender_full_name.split(' '):["",""];
row.nomatch = 1;
frappe.route_options = {
"email_id": row.sender,
"first_name": name_split[0],
@@ -320,7 +320,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
return
}
me.open_email = row.name
//mark email as read
if(me.account!="Sent") {
this.mark_read(row);
@@ -341,7 +341,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
me.company_select(row)
}}, 4000);
}
var c = me.prepare_email(row);
emailitem.fields_dict.email.$wrapper.html(frappe.render_template("inbox_email", {data:c}));
$(emailitem.$wrapper).find(".reply").find("a").attr("target", "_blank");
@@ -356,7 +356,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
me.delete_email({n:row.name, u:row.uid});
emailitem.hide()
});
$(emailitem.$wrapper).find(".company-link").on("click", function () {
me.company_select(row, true)});
me.add_reply_btn_event(emailitem, c);
@@ -365,12 +365,12 @@ frappe.Inbox = frappe.ui.Listing.extend({
$(".modal-dialog").addClass("modal-lg");
$(emailitem.$wrapper).find(".modal-title").parent().removeClass("col-xs-7").addClass("col-xs-7 col-sm-8 col-md-9");
$(emailitem.$wrapper).find(".text-right").parent().removeClass("col-xs-5").addClass("col-xs-5 col-sm-4 col-md-3");
//setup close
emailitem.onhide = function() {
me.open_email = null
}
emailitem.show();
},
add_reply_btn_event: function (emailitem, c) {
@@ -437,7 +437,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
forward:true,
attachments:c.attachments
});
$(communication.dialog.fields_dict.select_attachments.wrapper).find("input[type=checkbox]").prop("checked",true)
});
},
@@ -582,7 +582,7 @@ frappe.Inbox = frappe.ui.Listing.extend({
var names = [{name:data.name, uid:data.uid}]
}
//could add flag to sync deletes but not going to as keeps history
me.update_local_flags(names, "deleted", "1")
},
mark_unread:function(){


+ 0
- 0
frappe/geo/doctype/address/__init__.py 查看文件


+ 25
- 0
frappe/geo/doctype/address/address.js 查看文件

@@ -0,0 +1,25 @@
// Copyright (c) 2016, Frappe Technologies and contributors
// For license information, please see license.txt

frappe.ui.form.on("Address", {
refresh: function(frm) {
if(frm.doc.__islocal) {
var last_route = frappe.route_history.slice(-2, -1)[0];
if(frappe.contact_link && frappe.contact_link.doc
&& frappe.contact_link.doc.name==last_route[2]) {
frm.add_child('links', {
link_doctype: frappe.contact_link.doctype,
link_name: frappe.contact_link.doc[frappe.contact_link.fieldname]
});
}
}
},
validate: function(frm) {
// clear linked customer / supplier / sales partner on saving...
if(frm.doc.links) {
frm.doc.links.forEach(function(d) {
frappe.model.remove_from_locals(d.link_doctype, d.link_name);
});
}
}
});

+ 651
- 0
frappe/geo/doctype/address/address.json 查看文件

@@ -0,0 +1,651 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_rename": 1,
"beta": 0,
"creation": "2013-01-10 16:34:32",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "address_details",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "",
"length": 0,
"no_copy": 0,
"options": "fa fa-map-marker",
"permlevel": 0,
"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,
"description": "Name of person or organization that this address belongs to.",
"fieldname": "address_title",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Address Title",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "address_type",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Address Type",
"length": 0,
"no_copy": 0,
"options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther",
"permlevel": 0,
"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,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "address_line1",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Address Line 1",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "address_line2",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Address Line 2",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "city",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "City/Town",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "county",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "County",
"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": "state",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "State",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "country",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"in_standard_filter": 1,
"label": "Country",
"length": 0,
"no_copy": 0,
"options": "Country",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "pincode",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Postal Code",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break0",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"width": "50%"
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "email_id",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Email Address",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "phone",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Phone",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "fax",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Fax",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"default": "0",
"description": "",
"fieldname": "is_primary_address",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Preferred Billing Address",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"default": "0",
"description": "",
"fieldname": "is_shipping_address",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Preferred Shipping Address",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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": "linked_with",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Reference",
"length": 0,
"no_copy": 0,
"options": "fa fa-pushpin",
"permlevel": 0,
"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,
"default": "0",
"fieldname": "is_your_company_address",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Is Your Company Address",
"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": "links",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Links",
"length": 0,
"no_copy": 0,
"options": "Dynamic Link",
"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
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-map-marker",
"idx": 5,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-01-13 05:01:15.084023",
"modified_by": "Administrator",
"module": "Geo",
"name": "Address",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Maintenance User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
},
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 0,
"email": 1,
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts User",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "country, state",
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

+ 203
- 0
frappe/geo/doctype/address/address.py 查看文件

@@ -0,0 +1,203 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe

from frappe import throw, _
from frappe.utils import cstr

from frappe.model.document import Document
from jinja2 import TemplateSyntaxError
from frappe.utils.user import is_website_user
from frappe.model.naming import make_autoname

class Address(Document):
def __setup__(self):
self.flags.linked = False

def autoname(self):
if not self.address_title:
if self.links:
self.address_title = self.links[0].link_name

if self.address_title:
self.name = (cstr(self.address_title).strip() + "-" + cstr(self.address_type).strip())
if frappe.db.exists("Address", self.name):
self.name = make_autoname(cstr(self.address_title).strip() + "-" +
cstr(self.address_type).strip() + "-.#")
else:
throw(_("Address Title is mandatory."))

def validate(self):
self.link_address()
self.validate_reference()

def link_address(self):
"""Link address based on owner"""
if not self.links and not self.is_your_company_address:
contact_name = frappe.db.get_value("Contact", {"email_id": self.owner})
if contact_name:
contact = frappe.get_doc('Contact', contact_name)
for link in contact.links:
self.append('links', dict(link_doctype=link.link_doctype, link_name=link.link_name))
return True

return False

def validate_reference(self):
if self.is_your_company_address:
if not self.company:
frappe.throw(_("Company is mandatory, as it is your company address"))
if self.links:
self.links = []

def get_display(self):
return get_address_display(self.as_dict())

def has_link(self, doctype, name):
for link in self.links:
if link.link_doctype==doctype and link.link_name== name:
return True

def has_common_link(self, doc):
reference_links = [(link.link_doctype, link.link_name) for link in doc.links]
for link in self.links:
if (link.link_doctype, link.link_name) in reference_links:
return True

return False

def get_default_address(doctype, name, sort_key='is_primary_address'):
'''Returns default Address name for the given doctype, name'''
out = frappe.db.sql('''select address.name
from
tabAddress address, `tabDynamic Link` dl
where
dl.link_doctype=%s and
dl.link_name=%s and
dl.parent = address.name and
dl.parenttype = "Address"
order by
address.`{0}` desc, name
limit 1'''.format(sort_key), (doctype, name))
return out and out[0][0] or None


@frappe.whitelist()
def get_address_display(address_dict):
if not address_dict:
return

if not isinstance(address_dict, dict):
address_dict = frappe.db.get_value("Address", address_dict, "*", as_dict=True) or {}

name, template = get_address_templates(address_dict)

try:
return frappe.render_template(template, address_dict)
except TemplateSyntaxError:
frappe.throw(_("There is an error in your Address Template {0}").format(name))


def get_territory_from_address(address):
"""Tries to match city, state and country of address to existing territory"""
if not address:
return

if isinstance(address, basestring):
address = frappe.get_doc("Address", address)

territory = None
for fieldname in ("city", "state", "country"):
territory = frappe.db.get_value("Territory", address.get(fieldname))
if territory:
break

return territory

def get_list_context(context=None):
return {
"title": _("Addresses"),
"get_list": get_address_list,
"row_template": "templates/includes/address_row.html",
'no_breadcrumbs': True,
}

def get_address_list(doctype, txt, filters, limit_start, limit_page_length=20):
from frappe.www.list import get_list
user = frappe.session.user
ignore_permissions = False
if is_website_user():
if not filters: filters = []
filters.append(("Address", "owner", "=", user))
ignore_permissions = True

return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions)

def has_website_permission(doc, ptype, user, verbose=False):
"""Returns true if there is a related lead or contact related to this document"""
contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
if contact_name:
contact = frappe.get_doc('Contact', contact_name)
return contact.has_common_link(doc)

lead_name = frappe.db.get_value("Lead", {"email_id": frappe.session.user})
if lead_name:
return doc.has_link('Lead', lead_name)

return False

def get_address_templates(address):
result = frappe.db.get_value("Address Template", \
{"country": address.get("country")}, ["name", "template"])

if not result:
result = frappe.db.get_value("Address Template", \
{"is_default": 1}, ["name", "template"])

if not result:
frappe.throw(_("No default Address Template found. Please create a new one from Setup > Printing and Branding > Address Template."))
else:
return result

@frappe.whitelist()
def get_shipping_address(company):
filters = {"company": company, "is_your_company_address":1}
fieldname = ["name", "address_line1", "address_line2", "city", "state", "country"]

address_as_dict = frappe.db.get_value("Address", filters=filters, fieldname=fieldname, as_dict=True)

if address_as_dict:
name, address_template = get_address_templates(address_as_dict)
return address_as_dict.get("name"), frappe.render_template(address_template, address_as_dict)

def contact_query(doctype, txt, searchfield, start, page_len, filters):
from frappe.desk.reportview import get_match_cond

return frappe.db.sql("""select
address.name, address.city, address.country
from
tabAddress as address, `tabDynamic Link` as dl
where
dl.parent = address.name and
dl.parenttype = 'Address' and
dl.link_doctype = %(link_doctype)s and
dl.link_name = %(link_name)s and
address.`{key}` like %(txt)s
{mcond}
order by
if(locate(%(_txt)s, address.name), locate(%(_txt)s, address.name), 99999),
address.idx desc, address.name
limit %(start)s, %(page_len)s """.format(
mcond=get_match_cond(doctype),
key=frappe.db.escape(searchfield)),
{
'txt': "%%%s%%" % frappe.db.escape(txt),
'_txt': txt.replace("%", ""),
'start': start,
'page_len': page_len,
'link_doctype': filters.get('link_doctype'),
'link_name': filters.get('link_name')
})

+ 18
- 0
frappe/geo/doctype/address/test_address.py 查看文件

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe, unittest
test_records = frappe.get_test_records('Address')

from frappe.geo.doctype.address.address import get_address_display

class TestAddress(unittest.TestCase):
def test_template_works(self):
address = frappe.get_list("Address")[0].name
display = get_address_display(frappe.get_doc("Address", address).as_dict())
self.assertTrue(display)


test_dependencies = ["Address Template"]

+ 15
- 0
frappe/geo/doctype/address/test_records.json 查看文件

@@ -0,0 +1,15 @@
[
{
"address_line1": "_Test Address Line 1",
"address_title": "_Test Address",
"address_type": "Office",
"city": "_Test City",
"state": "Test State",
"country": "India",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"doctype": "Address",
"is_primary_address": 1,
"phone": "+91 0000000000"
}
]

+ 0
- 0
frappe/geo/doctype/address_template/__init__.py 查看文件


+ 16
- 0
frappe/geo/doctype/address_template/address_template.js 查看文件

@@ -0,0 +1,16 @@
// Copyright (c) 2016, Frappe Technologies and contributors
// For license information, please see license.txt

frappe.ui.form.on('Address Template', {
refresh: function(frm) {
if(frm.is_new() && !frm.doc.template) {
// set default template via js so that it is translated
frappe.call({
method: 'frappe.geo.doctype.address_template.address_template.get_default_address_template',
callback: function(r) {
frm.set_value('template', r.message);
}
});
}
}
});

+ 148
- 0
frappe/geo/doctype/address_template/address_template.json 查看文件

@@ -0,0 +1,148 @@
{
"allow_copy": 0,
"allow_import": 0,
"allow_rename": 1,
"autoname": "field:country",
"beta": 0,
"creation": "2014-06-05 02:22:36.029850",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"engine": "InnoDB",
"fields": [
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "country",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Country",
"length": 0,
"no_copy": 0,
"options": "Country",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 1,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "This format is used if country specific format is not found",
"fieldname": "is_default",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Is Default",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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,
"default": "",
"description": "<h4>Default Template</h4>\n<p>Uses <a href=\"http://jinja.pocoo.org/docs/templates/\">Jinja Templating</a> and all the fields of Address (including Custom Fields if any) will be available</p>\n<pre><code>{{ address_line1 }}&lt;br&gt;\n{% if address_line2 %}{{ address_line2 }}&lt;br&gt;{% endif -%}\n{{ city }}&lt;br&gt;\n{% if state %}{{ state }}&lt;br&gt;{% endif -%}\n{% if pincode %} PIN: {{ pincode }}&lt;br&gt;{% endif -%}\n{{ country }}&lt;br&gt;\n{% if phone %}Phone: {{ phone }}&lt;br&gt;{% endif -%}\n{% if fax %}Fax: {{ fax }}&lt;br&gt;{% endif -%}\n{% if email_id %}Email: {{ email_id }}&lt;br&gt;{% endif -%}\n</code></pre>",
"fieldname": "template",
"fieldtype": "Code",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Template",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"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
}
],
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-map-marker",
"idx": 0,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-01-13 05:11:37.499528",
"modified_by": "Administrator",
"module": "Geo",
"name": "Address Template",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"apply_user_permissions": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 0,
"export": 1,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 1,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}

+ 43
- 0
frappe/geo/doctype/address_template/address_template.py 查看文件

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
from frappe.utils.jinja import validate_template
from frappe import _

class AddressTemplate(Document):
def validate(self):
if not self.template:
self.template = get_default_address_template()

self.defaults = frappe.db.get_values("Address Template", {"is_default":1, "name":("!=", self.name)})
if not self.is_default:
if not self.defaults:
self.is_default = 1
frappe.msgprint(_("Setting this Address Template as default as there is no other default"))

validate_template(self.template)

def on_update(self):
if self.is_default and self.defaults:
for d in self.defaults:
frappe.db.set_value("Address Template", d[0], "is_default", 0)

def on_trash(self):
if self.is_default:
frappe.throw(_("Default Address Template cannot be deleted"))

@frappe.whitelist()
def get_default_address_template():
'''Get default address template (translated)'''
return '''{{ address_line1 }}<br>{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}\
{{ city }}<br>
{% if state %}{{ state }}<br>{% endif -%}
{% if pincode %}{{ pincode }}<br>{% endif -%}
{{ country }}<br>
{% if phone %}'''+_('Phone')+''': {{ phone }}<br>{% endif -%}
{% if fax %}'''+_('Fax')+''': {{ fax }}<br>{% endif -%}
{% if email_id %}'''+_('Email')+''': {{ email_id }}<br>{% endif -%}'''

+ 24
- 0
frappe/geo/doctype/address_template/test_address_template.py 查看文件

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals

import frappe, unittest
test_records = frappe.get_test_records('Address Template')

class TestAddressTemplate(unittest.TestCase):
def test_default_is_unset(self):
a = frappe.get_doc("Address Template", "India")
a.is_default = 1
a.save()

b = frappe.get_doc("Address Template", "Brazil")
b.is_default = 1
b.save()

self.assertEqual(frappe.db.get_value("Address Template", "India", "is_default"), 0)

def tearDown(self):
a = frappe.get_doc("Address Template", "India")
a.is_default = 1
a.save()

+ 13
- 0
frappe/geo/doctype/address_template/test_records.json 查看文件

@@ -0,0 +1,13 @@
[
{
"country": "India",
"is_default": 1,
"template": "{{ address_title }}<br>\n{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif %}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif %}\n{% if pincode %} PIN / ZIP: {{ pincode }}<br>{% endif %}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif %}\n{% if fax %}Fax: {{ fax }}<br>{% endif %}\n{% if email_id %}Email: {{ email_id }}<br>{% endif %}\n"
},
{
"country": "Brazil",
"is_default": 0,
"template": "{{ address_title }}<br>\n{{ address_line1 }}<br>\n{% if address_line2 %}{{ address_line2 }}<br>{% endif %}\n{{ city }}<br>\n{% if state %}{{ state }}<br>{% endif %}\n{% if pincode %} PIN / ZIP: {{ pincode }}<br>{% endif %}\n{{ country }}<br>\n{% if phone %}Phone: {{ phone }}<br>{% endif %}\n{% if fax %}Fax: {{ fax }}<br>{% endif %}\n{% if email_id %}Email: {{ email_id }}<br>{% endif %}\n"
}
]


+ 4
- 0
frappe/hooks.py 查看文件

@@ -91,6 +91,10 @@ has_permission = {
"Communication": "frappe.core.doctype.communication.communication.has_permission"
}

has_website_permission = {
"Address": "erpnext.utilities.doctype.address.address.has_website_permission"
}

standard_queries = {
"User": "frappe.core.doctype.user.user.user_query"
}


+ 0
- 4
frappe/patches.txt 查看文件

@@ -147,12 +147,8 @@ frappe.patches.v7_0.cleanup_list_settings
execute:frappe.db.set_default('language', '')
frappe.patches.v7_1.refactor_integration_broker
frappe.patches.v7_1.set_backup_limit
frappe.patches.v7_1.fix_email_sender
execute:frappe.db.sql("update tabCommunication SET docstatus = 0 where docstatus =2 or docstatus = 1")
execute:frappe.db.sql("update tabCommunication set communication_date = if(actualdate,actualdate,creation) where time(communication_date) = 0 or actualdate is not null")
frappe.patches.v7_1.disabled_print_settings_for_custom_print_format
frappe.patches.v7_2.set_doctype_engine
frappe.patches.v7_2.merge_knowledge_base
frappe.patches.v7_0.update_report_builder_json
frappe.patches.v7_2.match_emails_to_contacts
frappe.patches.v7_2.set_in_standard_filter_property #1

+ 0
- 12
frappe/patches/v7_1/fix_email_sender.py 查看文件

@@ -1,12 +0,0 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import extract_email_id
from inbox.email_inbox.contact import match_email_to_contact
def execute():
frappe.reload_doctype('Communication')
for c in frappe.db.sql("""select name,sender from tabCommunication where communication_type = 'Communication' and sender like '%<%>'""",as_dict=1):
frappe.db.set_value('Communication', c.name, 'sender',extract_email_id(c.sender) , update_modified=False)
communication = frappe.get_doc('Communication', c.name)
match_email_to_contact(communication)


+ 0
- 72
frappe/patches/v7_2/match_emails_to_contacts.py 查看文件

@@ -1,72 +0,0 @@
from __future__ import unicode_literals
import frappe
def execute():
frappe.db.sql("update `tabContact` set email_id = lower(email_id)")
frappe.db.sql("update `tabCommunication` set sender = lower(sender),recipients = lower(recipients)")


origin_contact = frappe.db.sql("select name,email_id,supplier,supplier_name,customer,customer_name,user,organisation from `tabContact` where email_id <>''",as_dict=1)
origin_communication = frappe.db.sql("select name, sender,recipients,sent_or_received from `tabCommunication` where communication_type = 'Communication'",as_dict=1)

for communication in origin_communication:
# format contacts
for comm in origin_contact:
if (communication.sender and communication.sent_or_received == "Received" and communication.sender.find(comm.email_id) > -1) \
or (communication.recipients !=None and communication.sent_or_received == "Sent" and communication.recipients.find(comm.email_id) > -1):
if sum(1 for x in [comm.supplier, comm.customer, comm.user,comm.organisation] if x) > 1:
frappe.db.sql("""update `tabCommunication`
set timeline_doctype = %(timeline_doctype)s,
timeline_name = %(timeline_name)s,
timeline_label = %(timeline_label)s
where name = %(name)s""", {
"timeline_doctype": "Contact",
"timeline_name": comm.name,
"timeline_label": comm.name,
"name": communication.name
})

elif comm.supplier:
frappe.db.sql("""update `tabCommunication`
set timeline_doctype = %(timeline_doctype)s,
timeline_name = %(timeline_name)s,
timeline_label = %(timeline_label)s
where name = %(name)s""", {
"timeline_doctype": "Supplier",
"timeline_name": comm.supplier,
"timeline_label": comm.supplier_name,
"name": communication.name
})

elif comm.customer:
frappe.db.sql("""update `tabCommunication`
set timeline_doctype = %(timeline_doctype)s,
timeline_name = %(timeline_name)s,
timeline_label = %(timeline_label)s
where name = %(name)s""", {
"timeline_doctype": "Customer",
"timeline_name": comm.customer,
"timeline_label": comm.customer_name,
"name": communication.name
})
elif comm.user:
frappe.db.sql("""update `tabCommunication`
set timeline_doctype = %(timeline_doctype)s,
timeline_name = %(timeline_name)s,
timeline_label = %(timeline_label)s
where name = %(name)s""", {
"timeline_doctype": "User",
"timeline_name": comm.user,
"timeline_label": comm.user,
"name": communication.name
})
elif comm.organisation:
frappe.db.sql("""update `tabCommunication`
set timeline_doctype = %(timeline_doctype)s,
timeline_name = %(timeline_name)s,
timeline_label = %(timeline_label)s
where name = %(name)s""", {
"timeline_doctype": "Organisation",
"timeline_name": comm.organisation,
"timeline_label": comm.organisation,
"name": communication.name
})

+ 3
- 1
frappe/public/js/legacy/clientscriptAPI.js 查看文件

@@ -248,7 +248,9 @@ _f.Frm.prototype.set_query = function(fieldname, opt1, opt2) {
} else {
// on parent table
// set_query(fieldname, query)
this.fields_dict[fieldname].get_query = opt1;
if(this.fields_dict[fieldname]) {
this.fields_dict[fieldname].get_query = opt1;
}
}
}



Loading…
取消
儲存