Merge branch 'develop' of https://github.com/frappe/frappe into rebuild_tree
This commit is contained in:
commit
d3dbd74a0a
13 changed files with 106 additions and 41 deletions
|
|
@ -147,6 +147,7 @@
|
|||
"context": true,
|
||||
"before": true,
|
||||
"beforeEach": true,
|
||||
"qz": true
|
||||
"qz": true,
|
||||
"localforage": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,10 +152,10 @@ def process_response(response):
|
|||
|
||||
def set_cors_headers(response):
|
||||
origin = frappe.request.headers.get('Origin')
|
||||
if not origin:
|
||||
allow_cors = frappe.conf.allow_cors
|
||||
if not (origin and allow_cors):
|
||||
return
|
||||
|
||||
allow_cors = frappe.conf.allow_cors
|
||||
if allow_cors != "*":
|
||||
if not isinstance(allow_cors, list):
|
||||
allow_cors = [allow_cors]
|
||||
|
|
|
|||
|
|
@ -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)):
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ frappe.patches.v11_0.change_email_signature_fieldtype
|
|||
execute:frappe.reload_doc('core', 'doctype', 'activity_log')
|
||||
execute:frappe.reload_doc('core', 'doctype', 'deleted_document')
|
||||
execute:frappe.reload_doc('core', 'doctype', 'domain_settings')
|
||||
frappe.patches.v13_0.rename_custom_client_script
|
||||
frappe.patches.v8_0.rename_page_role_to_has_role #2017-03-16
|
||||
frappe.patches.v7_2.setup_custom_perms #2017-01-19
|
||||
frappe.patches.v8_0.set_user_permission_for_page_and_report #2017-03-20
|
||||
|
|
@ -330,4 +331,3 @@ execute:frappe.get_doc('Role', 'Guest').save() # remove desk access
|
|||
frappe.patches.v13_0.rename_desk_page_to_workspace # 02.02.2021
|
||||
frappe.patches.v13_0.delete_package_publish_tool
|
||||
frappe.patches.v13_0.rename_list_view_setting_to_list_view_settings
|
||||
frappe.patches.v13_0.rename_custom_client_script
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('core', 'doctype', 'user')
|
||||
frappe.db.sql('''
|
||||
UPDATE `tabUser`
|
||||
SET `home_settings` = ''
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ from __future__ import unicode_literals
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
"""Enable all the existing custom script"""
|
||||
frappe.reload_doc("Custom", "doctype", "Custom Script")
|
||||
"""Enable all the existing Client script"""
|
||||
|
||||
frappe.db.sql("""
|
||||
UPDATE `tabCustom Script` SET enabled=1
|
||||
UPDATE `tabClient Script` SET enabled=1
|
||||
""")
|
||||
|
|
@ -100,6 +100,7 @@
|
|||
"node_modules/moment/min/moment-with-locales.min.js",
|
||||
"node_modules/moment-timezone/builds/moment-timezone-with-data.min.js",
|
||||
"node_modules/socket.io-client/dist/socket.io.slim.js",
|
||||
"node_modules/localforage/dist/localforage.min.js",
|
||||
"public/js/lib/jSignature.min.js",
|
||||
"public/js/lib/leaflet/leaflet.js",
|
||||
"public/js/lib/leaflet/leaflet.draw.js",
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@
|
|||
<path d="M16.127 13.077l3.194 3.194a2.588 2.588 0 0 1 0 3.66 2.589 2.589 0 0 1-3.66 0l-2.902-2.902" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M11.315 10.095l-4.96-4.96a1.294 1.294 0 1 0-1.83 1.83l4.877 4.877" stroke="var(--icon-stroke)" stroke-miterlimit="10"></path>
|
||||
<path d="M18.56 11.949l-.353.353a.5.5 0 0 0 .707 0l-.354-.353zM21 9.509l.354.353a.5.5 0 0 0 0-.705L21 9.509zm-5.47-5.51l.354-.352-.004-.004-.35.357zm-4.9.02l-.353-.353a.5.5 0 0 0 0 .707l.353-.354zm8.284 8.283l2.44-2.44-.707-.707-2.44 2.44.707.707zm2.44-3.145l-5.47-5.51-.71.705 5.471 5.51.71-.705zM15.88 3.643A3.977 3.977 0 0 0 13.074 2.5l.004 1a2.977 2.977 0 0 1 2.1.856l.702-.713zM13.074 2.5a3.977 3.977 0 0 0-2.797 1.166l.707.706a2.977 2.977 0 0 1 2.094-.872l-.004-1zm-2.797 1.873l7.93 7.93.707-.708-7.93-7.93-.707.708z"
|
||||
fill="#4C5A67" stroke="none"></path>
|
||||
fill="var(--icon-stroke)" stroke="none"></path>
|
||||
<path d="M14.133 7.522L3.398 17.325a1.219 1.219 0 0 0-.04 1.764L4.6 20.331a1.22 1.22 0 0 0 1.764-.04l9.789-10.75" stroke="var(--icon-stroke)" stroke-miterlimit="10"></path>
|
||||
</symbol>
|
||||
<symbol viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="icon-support">
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
|
|
@ -591,26 +591,28 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
|
||||
save_as_draft: function() {
|
||||
if (this.dialog && this.frm) {
|
||||
try {
|
||||
let message = this.dialog.get_value('content');
|
||||
message = message.split(frappe.separator_element)[0];
|
||||
localStorage.setItem(this.frm.doctype + this.frm.docname, message);
|
||||
} catch (e) {
|
||||
// silently fail
|
||||
console.log(e);
|
||||
console.warn('[Communication] localStorage is full. Cannot save message as draft');
|
||||
}
|
||||
let message = this.dialog.get_value('content');
|
||||
message = message.split(frappe.separator_element)[0];
|
||||
localforage.setItem(this.frm.doctype + this.frm.docname, message).catch(e => {
|
||||
if (e) {
|
||||
// silently fail
|
||||
console.log(e); // eslint-disable-line
|
||||
console.warn('[Communication] localStorage is full. Cannot save message as draft'); // eslint-disable-line
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
delete_saved_draft() {
|
||||
if (this.dialog) {
|
||||
try {
|
||||
localStorage.removeItem(this.frm.doctype + this.frm.docname);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.warn('[Communication] Cannot delete localStorage item'); // eslint-disable-line
|
||||
}
|
||||
localforage.getItem(this.frm.doctype + this.frm.docname).catch(e => {
|
||||
if (e) {
|
||||
// silently fail
|
||||
console.log(e); // eslint-disable-line
|
||||
console.warn('[Communication] localStorage is full. Cannot save message as draft'); // eslint-disable-line
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -721,7 +723,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
signature = res.message.signature;
|
||||
}
|
||||
|
||||
if(!frappe.utils.is_html(signature)) {
|
||||
if (signature && !frappe.utils.is_html(signature)) {
|
||||
signature = signature.replace(/\n/g, "<br>");
|
||||
}
|
||||
|
||||
|
|
@ -731,7 +733,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
// saved draft in localStorage
|
||||
const { doctype, docname } = this.frm || {};
|
||||
if (doctype && docname) {
|
||||
this.message = localStorage.getItem(doctype + docname) || '';
|
||||
this.message = await localforage.getItem(doctype + docname) || '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
"highlight.js": "^10.4.1",
|
||||
"js-sha256": "^0.9.0",
|
||||
"jsbarcode": "^3.9.0",
|
||||
"localforage": "^1.9.0",
|
||||
"moment": "^2.20.1",
|
||||
"moment-timezone": "^0.5.28",
|
||||
"node-sass": "^4.14.1",
|
||||
|
|
|
|||
27
yarn.lock
27
yarn.lock
|
|
@ -961,15 +961,10 @@ caniuse-api@^3.0.0:
|
|||
lodash.memoize "^4.1.2"
|
||||
lodash.uniq "^4.5.0"
|
||||
|
||||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000939:
|
||||
version "1.0.30001116"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001116.tgz"
|
||||
integrity sha512-f2lcYnmAI5Mst9+g0nkMIznFGsArRmZ0qU+dnq8l91hymdc2J3SFbiPhOJEeDqC1vtE8nc1qNQyklzB8veJefQ==
|
||||
|
||||
caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001111:
|
||||
version "1.0.30001118"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001118.tgz#116a9a670e5264aec895207f5e918129174c6f62"
|
||||
integrity sha512-RNKPLojZo74a0cP7jFMidQI7nvLER40HgNfgKQEJ2PFm225L0ectUungNQoK3Xk3StQcFbpBPNEvoWD59436Hg==
|
||||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000939, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001111:
|
||||
version "1.0.30001191"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001191.tgz"
|
||||
integrity sha512-xJJqzyd+7GCJXkcoBiQ1GuxEiOBCLQ0aVW9HMekifZsAVGdj5eJ4mFB9fEhSHipq9IOk/QXFJUiIr9lZT+EsGw==
|
||||
|
||||
caseless@~0.12.0:
|
||||
version "0.12.0"
|
||||
|
|
@ -3790,6 +3785,13 @@ levn@~0.3.0:
|
|||
prelude-ls "~1.1.2"
|
||||
type-check "~0.3.2"
|
||||
|
||||
lie@3.1.1:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e"
|
||||
integrity sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=
|
||||
dependencies:
|
||||
immediate "~3.0.5"
|
||||
|
||||
lie@~3.3.0:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a"
|
||||
|
|
@ -3823,6 +3825,13 @@ loadjs@^4.2.0:
|
|||
resolved "https://registry.yarnpkg.com/loadjs/-/loadjs-4.2.0.tgz#2a0336376397a6a43edf98c9ec3229ddd5abb6f6"
|
||||
integrity sha512-AgQGZisAlTPbTEzrHPb6q+NYBMD+DP9uvGSIjSUM5uG+0jG15cb8axWpxuOIqrmQjn6scaaH8JwloiP27b2KXA==
|
||||
|
||||
localforage@^1.9.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.9.0.tgz#f3e4d32a8300b362b4634cc4e066d9d00d2f09d1"
|
||||
integrity sha512-rR1oyNrKulpe+VM9cYmcFn6tsHuokyVHFaCM3+osEmxaHTbEk8oQu6eGDfS6DQLWi/N67XRmB8ECG37OES368g==
|
||||
dependencies:
|
||||
lie "3.1.1"
|
||||
|
||||
locate-path@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue