Skip to content

Commit d1e3d9b

Browse files
committed
Merge branch 'staging' into production
2 parents f69f1e0 + 2cf4f42 commit d1e3d9b

File tree

32 files changed

+500
-907
lines changed

32 files changed

+500
-907
lines changed

frappe/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
sys.setdefaultencoding("utf-8")
2525

2626
__frappe_version__ = '12.8.1'
27-
__version__ = '2.0.14'
27+
__version__ = '2.1.0'
2828
__title__ = "Frappe Framework"
2929

3030
local = Local()

frappe/boot.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def get_bootinfo():
7272
bootinfo.lang = text_type(bootinfo.lang)
7373
bootinfo.versions = {k: v['version'] for k, v in get_versions().items()}
7474

75+
bootinfo.default_country = get_default_country()
7576
bootinfo.error_report_email = frappe.conf.error_report_email or frappe.get_hooks("error_report_email")
7677
bootinfo.calendars = sorted(frappe.get_hooks("calendars"))
7778
bootinfo.treeviews = frappe.get_hooks("treeviews") or []
@@ -273,4 +274,18 @@ def doctypes_with_show_link_field_title():
273274
dts = frappe.get_all("DocType", {"show_title_field_in_link": 1})
274275
custom_dts = frappe.get_all("Property Setter", {"field_name": "show_title_field_in_link", "value": 1})
275276

276-
return [d.name for d in dts + custom_dts if d]
277+
return [d.name for d in dts + custom_dts if d]
278+
279+
def get_default_country():
280+
if not (frappe.db.exists("DocType", "System Settings") and frappe.db.exists("DocType", "Country")):
281+
return {}
282+
283+
country = frappe.get_value("System Settings", "System Settings", "country")
284+
if not country:
285+
return {}
286+
287+
country = frappe.get_doc("Country", country)
288+
return {
289+
"country": country.name,
290+
"code": country.code
291+
}

frappe/contacts/doctype/contact/contact.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"allow_events_in_timeline": 1,
33
"allow_import": 1,
44
"allow_rename": 1,
5+
"autoname": "Contact-.####",
56
"creation": "2013-01-10 16:34:32",
67
"doctype": "DocType",
78
"document_type": "Setup",
@@ -39,7 +40,8 @@
3940
"links",
4041
"more_info",
4142
"department",
42-
"unsubscribed"
43+
"unsubscribed",
44+
"title"
4345
],
4446
"fields": [
4547
{
@@ -243,6 +245,12 @@
243245
"fieldtype": "Data",
244246
"label": "Company Name"
245247
},
248+
{
249+
"fieldname": "title",
250+
"fieldtype": "Data",
251+
"hidden": 1,
252+
"label": "title"
253+
},
246254
{
247255
"fetch_from": "address.country",
248256
"fieldname": "country",
@@ -261,7 +269,7 @@
261269
"icon": "fa fa-user",
262270
"idx": 1,
263271
"image_field": "image",
264-
"modified": "2021-02-23 06:40:54.152210",
272+
"modified": "2021-03-21 22:46:46.221645",
265273
"modified_by": "Administrator",
266274
"module": "Contacts",
267275
"name": "Contact",
@@ -391,6 +399,8 @@
391399
"role": "All"
392400
}
393401
],
402+
"show_title_field_in_link": 1,
394403
"sort_field": "modified",
395-
"sort_order": "ASC"
404+
"sort_order": "ASC",
405+
"title_field": "title"
396406
}

frappe/contacts/doctype/contact/contact.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,11 @@
1515
import functools
1616

1717
class Contact(Document):
18-
def autoname(self):
19-
# concat first and last name
20-
self.name = " ".join(filter(None,
21-
[cstr(self.get(f)).strip() for f in ["first_name", "last_name"]]))
22-
23-
if frappe.db.exists("Contact", self.name):
24-
self.name = append_number_if_name_exists('Contact', self.name)
25-
26-
# concat party name if reqd
27-
for link in self.links:
28-
self.name = self.name + '-' + link.link_name.strip()
29-
break
30-
3118
def validate(self):
3219
self.set_primary_email()
3320
self.set_primary("phone")
3421
self.set_primary("mobile_no")
22+
self.set_title()
3523

3624
self.set_user()
3725

@@ -122,6 +110,17 @@ def set_primary(self, fieldname):
122110
setattr(self, fieldname, d.phone)
123111
break
124112

113+
def set_title(self):
114+
self.title = "{0} {1}".format(self.first_name, self.last_name)
115+
116+
if frappe.db.exists("Contact", {"title": self.title}):
117+
self.title = append_number_if_name_exists('Contact', self.title)
118+
119+
# concat party name if reqd
120+
for link in self.links:
121+
self.title = self.title + '-' + link.link_name.strip()
122+
break
123+
125124
def get_default_contact(doctype, name):
126125
'''Returns default contact for the given doctype, name'''
127126
out = frappe.db.sql('''select parent,

0 commit comments

Comments
 (0)