Merge branch 'develop' of https://github.com/frappe/frappe into comm_ref
This commit is contained in:
commit
a4478afcd5
14 changed files with 41 additions and 10 deletions
|
|
@ -152,3 +152,11 @@ def filter_dynamic_link_doctypes(doctype, txt, searchfield, start, page_len, fil
|
|||
valid_doctypes = [[doctype] for doctype in valid_doctypes]
|
||||
|
||||
return valid_doctypes
|
||||
|
||||
def set_link_title(doc):
|
||||
if not doc.links:
|
||||
return
|
||||
for link in doc.links:
|
||||
if not link.link_title:
|
||||
linked_doc = frappe.get_doc(link.link_doctype, link.link_name)
|
||||
link.link_title = linked_doc.get("title_field") or linked_doc.get("name")
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from frappe.model.naming import make_autoname
|
|||
from frappe.core.doctype.dynamic_link.dynamic_link import deduplicate_dynamic_links
|
||||
from six import iteritems, string_types
|
||||
from past.builtins import cmp
|
||||
from frappe.contacts.address_and_contact import set_link_title
|
||||
|
||||
import functools
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ class Address(Document):
|
|||
def validate(self):
|
||||
self.link_address()
|
||||
self.validate_reference()
|
||||
set_link_title(self)
|
||||
deduplicate_dynamic_links(self)
|
||||
|
||||
def link_address(self):
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from frappe.core.doctype.dynamic_link.dynamic_link import deduplicate_dynamic_li
|
|||
from six import iteritems
|
||||
from past.builtins import cmp
|
||||
from frappe.model.naming import append_number_if_name_exists
|
||||
from frappe.contacts.address_and_contact import set_link_title
|
||||
|
||||
import functools
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ class Contact(Document):
|
|||
if self.email_id:
|
||||
self.email_id = self.email_id.strip()
|
||||
self.set_user()
|
||||
set_link_title(self)
|
||||
if self.email_id and not self.image:
|
||||
self.image = has_gravatar(self.email_id)
|
||||
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ def run_background(prepared_report):
|
|||
instance.status = "Completed"
|
||||
instance.columns = json.dumps(result["columns"])
|
||||
instance.report_end_time = frappe.utils.now()
|
||||
instance.save()
|
||||
instance.save(ignore_permissions=True)
|
||||
|
||||
except Exception:
|
||||
frappe.log_error(frappe.get_traceback())
|
||||
instance = frappe.get_doc("Prepared Report", prepared_report)
|
||||
instance.status = "Error"
|
||||
instance.error_message = frappe.get_traceback()
|
||||
instance.save()
|
||||
instance.save(ignore_permissions=True)
|
||||
|
||||
frappe.publish_realtime(
|
||||
'report_generated',
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ def get_filters(search_by, name, frequency, user):
|
|||
elif frequency == "Hourly":
|
||||
filters = [
|
||||
[search_by, "=", name],
|
||||
["modified", ">", frappe.utils.add_to_date(frappe.utils.now_datetime(), 0, 0, 0, -1)],
|
||||
["modified", ">", frappe.utils.add_to_date(frappe.utils.now_datetime(), hours=-1)],
|
||||
["modified", "<", frappe.utils.now_datetime()],
|
||||
["modified_by", "!=", user]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ def make_records(records, debug=False):
|
|||
# pass DuplicateEntryError and continue
|
||||
if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name:
|
||||
# make sure DuplicateEntryError is for the exact same doc and not a related doc
|
||||
pass
|
||||
frappe.clear_messages()
|
||||
else:
|
||||
raise
|
||||
|
||||
|
|
|
|||
|
|
@ -282,6 +282,10 @@ def export_query():
|
|||
filters = json.loads(data["filters"])
|
||||
if isinstance(data.get("report_name"), string_types):
|
||||
report_name = data["report_name"]
|
||||
frappe.permissions.can_export(
|
||||
frappe.get_cached_value('Report', report_name, 'ref_doctype'),
|
||||
raise_exception=True
|
||||
)
|
||||
if isinstance(data.get("file_format_type"), string_types):
|
||||
file_format_type = data["file_format_type"]
|
||||
|
||||
|
|
|
|||
|
|
@ -2330,6 +2330,7 @@
|
|||
},
|
||||
"Suriname": {
|
||||
"code": "sr",
|
||||
"currency": "SRD",
|
||||
"currency_fraction": "Cent",
|
||||
"currency_fraction_units": 100,
|
||||
"currency_symbol": "$",
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ def validate_rename(doctype, new, meta, merge, force, ignore_permissions):
|
|||
if (not merge) and exists:
|
||||
frappe.msgprint(_("Another {0} with name {1} exists, select another name").format(doctype, new), raise_exception=1)
|
||||
|
||||
if not (ignore_permissions or frappe.has_permission(doctype, "write")):
|
||||
if not (ignore_permissions or frappe.permissions.has_permission(doctype, "write", raise_exception=False)):
|
||||
frappe.msgprint(_("You need write permission to rename"), raise_exception=1)
|
||||
|
||||
if not (force or ignore_permissions) and not meta.allow_rename:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import re
|
|||
def execute():
|
||||
""" Create Contact for each User if not present """
|
||||
frappe.reload_doc('contacts', 'doctype', 'contact')
|
||||
frappe.reload_doc('core', 'doctype', 'dynamic_link')
|
||||
|
||||
users = frappe.get_all('User', filters={"name": ('not in', 'Administrator, Guest')}, fields=["*"])
|
||||
for user in users:
|
||||
|
|
|
|||
|
|
@ -25,16 +25,18 @@ def print_has_permission_check_logs(func):
|
|||
frappe.flags['has_permission_check_logs'] = []
|
||||
result = func(*args, **kwargs)
|
||||
self_perm_check = True if not kwargs.get('user') else kwargs.get('user') == frappe.session.user
|
||||
raise_exception = False if kwargs.get('raise_exception') == False else True
|
||||
|
||||
# print only if access denied
|
||||
# and if user is checking his own permission
|
||||
if not result and self_perm_check:
|
||||
if not result and self_perm_check and raise_exception:
|
||||
msgprint(('<br>').join(frappe.flags.get('has_permission_check_logs')))
|
||||
frappe.flags.pop('has_permission_check_logs', None)
|
||||
return result
|
||||
return inner
|
||||
|
||||
@print_has_permission_check_logs
|
||||
def has_permission(doctype, ptype="read", doc=None, verbose=False, user=None):
|
||||
def has_permission(doctype, ptype="read", doc=None, verbose=False, user=None, raise_exception=True):
|
||||
"""Returns True if user has permission `ptype` for given `doctype`.
|
||||
If `doc` is passed, it also checks user, share and owner permissions.
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,10 @@ frappe.Application = Class.extend({
|
|||
refresh_notifications: function() {
|
||||
var me = this;
|
||||
if(frappe.session_alive && frappe.boot && frappe.boot.home_page !== 'setup-wizard') {
|
||||
return frappe.call({
|
||||
if (this._refresh_notifications) {
|
||||
this._refresh_notifications.abort();
|
||||
}
|
||||
this._refresh_notifications = frappe.call({
|
||||
type: 'GET',
|
||||
method: "frappe.desk.notifications.get_notifications",
|
||||
callback: function(r) {
|
||||
|
|
|
|||
|
|
@ -970,6 +970,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
{
|
||||
label: __('Export'),
|
||||
action: () => this.export_report(),
|
||||
condition: () => frappe.model.can_export(this.report_doc.ref_doctype),
|
||||
standard: true
|
||||
},
|
||||
{
|
||||
|
|
@ -991,9 +992,11 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
|
|||
change: () => {
|
||||
let doctype = d.get_value('doctype');
|
||||
frappe.model.with_doctype(doctype, () => {
|
||||
let fields = frappe.meta.get_docfields(doctype)
|
||||
let options = frappe.meta.get_docfields(doctype)
|
||||
.filter(frappe.model.is_value_type)
|
||||
.map(df => ({ label: df.label, value: df.fieldname }));
|
||||
d.set_df_property('field', 'options', fields);
|
||||
|
||||
d.set_df_property('field', 'options', options);
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ def add_years(date, years):
|
|||
def date_diff(string_ed_date, string_st_date):
|
||||
return (getdate(string_ed_date) - getdate(string_st_date)).days
|
||||
|
||||
def month_diff(string_ed_date, string_st_date):
|
||||
ed_date = getdate(string_ed_date)
|
||||
st_date = getdate(string_st_date)
|
||||
return (ed_date.year - st_date.year) * 12 + ed_date.month - st_date.month + 1
|
||||
|
||||
def time_diff(string_ed_date, string_st_date):
|
||||
return get_datetime(string_ed_date) - get_datetime(string_st_date)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue