Merge branch 'develop' of https://github.com/frappe/frappe into develop
This commit is contained in:
commit
3f383e932a
4 changed files with 59 additions and 7 deletions
|
|
@ -80,13 +80,15 @@ def search_widget(doctype, txt, query=None, searchfield=None, start=0,
|
|||
is_whitelisted(frappe.get_attr(query))
|
||||
frappe.response["values"] = frappe.call(query, doctype, txt,
|
||||
searchfield, start, page_length, filters, as_dict=as_dict)
|
||||
except Exception as e:
|
||||
except frappe.exceptions.PermissionError as e:
|
||||
if frappe.local.conf.developer_mode:
|
||||
raise e
|
||||
else:
|
||||
frappe.respond_as_web_page(title='Invalid Method', html='Method not found',
|
||||
indicator_color='red', http_status_code=404)
|
||||
return
|
||||
except Exception as e:
|
||||
raise e
|
||||
elif not query and doctype in standard_queries:
|
||||
# from standard queries
|
||||
search_widget(doctype, txt, standard_queries[doctype][0],
|
||||
|
|
|
|||
|
|
@ -69,13 +69,13 @@ def get_controller(doctype):
|
|||
|
||||
if frappe.local.dev_server:
|
||||
return _get_controller()
|
||||
|
||||
|
||||
site_controllers = frappe.controllers.setdefault(frappe.local.site, {})
|
||||
if doctype not in site_controllers:
|
||||
site_controllers[doctype] = _get_controller()
|
||||
|
||||
|
||||
return site_controllers[doctype]
|
||||
|
||||
|
||||
class BaseDocument(object):
|
||||
ignore_in_getter = ("doctype", "_meta", "meta", "_table_fields", "_valid_columns")
|
||||
|
||||
|
|
@ -94,6 +94,14 @@ class BaseDocument(object):
|
|||
return self._meta
|
||||
|
||||
def update(self, d):
|
||||
""" Update multiple fields of a doctype using a dictionary of key-value pairs.
|
||||
|
||||
Example:
|
||||
doc.update({
|
||||
"user": "admin",
|
||||
"balance": 42000
|
||||
})
|
||||
"""
|
||||
if "doctype" in d:
|
||||
self.set("doctype", d.get("doctype"))
|
||||
|
||||
|
|
@ -159,6 +167,15 @@ class BaseDocument(object):
|
|||
del self.__dict__[key]
|
||||
|
||||
def append(self, key, value=None):
|
||||
""" Append an item to a child table.
|
||||
|
||||
Example:
|
||||
doc.append("childtable", {
|
||||
"child_table_field": "value",
|
||||
"child_table_int_field": 0,
|
||||
...
|
||||
})
|
||||
"""
|
||||
if value==None:
|
||||
value={}
|
||||
if isinstance(value, (dict, BaseDocument)):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('core', 'doctype', 'user')
|
||||
frappe.db.sql('''
|
||||
UPDATE `tabUser`
|
||||
SET `home_settings` = ''
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ def is_invalid_date_string(date_string):
|
|||
# datetime functions
|
||||
def getdate(string_date=None):
|
||||
"""
|
||||
Converts string date (yyyy-mm-dd) to datetime.date object
|
||||
Converts string date (yyyy-mm-dd) to datetime.date object.
|
||||
If no input is provided, current date is returned.
|
||||
"""
|
||||
|
||||
if not string_date:
|
||||
|
|
@ -518,7 +519,25 @@ def cast_fieldtype(fieldtype, value):
|
|||
return value
|
||||
|
||||
def flt(s, precision=None):
|
||||
"""Convert to float (ignore commas)"""
|
||||
"""Convert to float (ignoring commas in string)
|
||||
|
||||
:param s: Number in string or other numeric format.
|
||||
:param precision: optional argument to specify precision for rounding.
|
||||
:returns: Converted number in python float type.
|
||||
|
||||
Returns 0 if input can not be converted to float.
|
||||
|
||||
Examples:
|
||||
|
||||
>>> flt("43.5", precision=0)
|
||||
44
|
||||
>>> flt("42.5", precision=0)
|
||||
42
|
||||
>>> flt("10,500.5666", precision=2)
|
||||
10500.57
|
||||
>>> flt("a")
|
||||
0.0
|
||||
"""
|
||||
if isinstance(s, string_types):
|
||||
s = s.replace(',','')
|
||||
|
||||
|
|
@ -532,7 +551,20 @@ def flt(s, precision=None):
|
|||
return num
|
||||
|
||||
def cint(s):
|
||||
"""Convert to integer"""
|
||||
"""Convert to integer
|
||||
|
||||
:param s: Number in string or other numeric format.
|
||||
:returns: Converted number in python integer type.
|
||||
|
||||
Returns 0 if input can not be converted to integer.
|
||||
|
||||
Examples:
|
||||
>>> cint("100")
|
||||
100
|
||||
>>> cint("a")
|
||||
0
|
||||
|
||||
"""
|
||||
try: num = int(float(s))
|
||||
except: num = 0
|
||||
return num
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue