@@ -5,7 +5,7 @@ pull_request_rules: | |||
- status-success=Semantic Pull Request | |||
- status-success=Travis CI - Pull Request | |||
- status-success=security/snyk (frappe) | |||
- label!=don't-merge | |||
- label!=dont-merge | |||
- label!=squash | |||
- "#approved-reviews-by>=1" | |||
actions: | |||
@@ -17,7 +17,7 @@ pull_request_rules: | |||
- status-success=Semantic Pull Request | |||
- status-success=Travis CI - Pull Request | |||
- status-success=security/snyk (frappe) | |||
- label!=don't-merge | |||
- label!=dont-merge | |||
- label=squash | |||
- "#approved-reviews-by>=1" | |||
actions: | |||
@@ -13,6 +13,7 @@ | |||
"fieldname", | |||
"precision", | |||
"length", | |||
"non_negative", | |||
"hide_days", | |||
"hide_seconds", | |||
"reqd", | |||
@@ -473,13 +474,20 @@ | |||
"fieldname": "hide_border", | |||
"fieldtype": "Check", | |||
"label": "Hide Border" | |||
}, | |||
{ | |||
"default": "0", | |||
"depends_on": "eval:in_list([\"Int\", \"Float\", \"Currency\"], doc.fieldtype)", | |||
"fieldname": "non_negative", | |||
"fieldtype": "Check", | |||
"label": "Non Negative" | |||
} | |||
], | |||
"idx": 1, | |||
"index_web_pages_for_search": 1, | |||
"istable": 1, | |||
"links": [], | |||
"modified": "2020-08-28 11:28:21.252853", | |||
"modified": "2020-10-29 06:09:26.454990", | |||
"modified_by": "Administrator", | |||
"module": "Core", | |||
"name": "DocField", | |||
@@ -34,7 +34,8 @@ | |||
"fieldname": "prefix", | |||
"fieldtype": "Data", | |||
"label": "Prefix", | |||
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\"" | |||
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\"", | |||
"reqd": 1 | |||
}, | |||
{ | |||
"fieldname": "counter", | |||
@@ -48,7 +49,8 @@ | |||
"fieldname": "prefix_digits", | |||
"fieldtype": "Int", | |||
"label": "Digits", | |||
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\"" | |||
"mandatory_depends_on": "eval:doc.naming_by===\"Numbered\"", | |||
"reqd": 1 | |||
}, | |||
{ | |||
"fieldname": "naming_section", | |||
@@ -69,7 +71,7 @@ | |||
"options": "Document Naming Rule Condition" | |||
}, | |||
{ | |||
"description": "Rules with higher priority will be applied first.", | |||
"description": "Rules with higher priority number will be applied first.", | |||
"fieldname": "priority", | |||
"fieldtype": "Int", | |||
"label": "Priority" | |||
@@ -77,7 +79,7 @@ | |||
], | |||
"index_web_pages_for_search": 1, | |||
"links": [], | |||
"modified": "2020-09-21 10:23:34.401539", | |||
"modified": "2020-11-04 14:38:14.836056", | |||
"modified_by": "Administrator", | |||
"module": "Core", | |||
"name": "Document Naming Rule", | |||
@@ -13,7 +13,7 @@ class DocumentNamingRule(Document): | |||
Apply naming rules for the given document. Will set `name` if the rule is matched. | |||
''' | |||
if self.conditions: | |||
if not evaluate_filters(doc, [(d.field, d.condition, d.value) for d in self.conditions]): | |||
if not evaluate_filters(doc, [(self.document_type, d.field, d.condition, d.value) for d in self.conditions]): | |||
return | |||
counter = frappe.db.get_value(self.doctype, self.name, 'counter', for_update=True) or 0 | |||
@@ -2,7 +2,9 @@ frappe.ui.form.on('Report', { | |||
refresh: function(frm) { | |||
if (frm.doc.is_standard === "Yes" && !frappe.boot.developer_mode) { | |||
// make the document read-only | |||
frm.set_read_only(); | |||
frm.disable_form(); | |||
} else { | |||
frm.enable_save(); | |||
} | |||
let doc = frm.doc; | |||
@@ -32,8 +34,6 @@ frappe.ui.form.on('Report', { | |||
}); | |||
}, doc.disabled ? "fa fa-check" : "fa fa-off"); | |||
} | |||
frm.events.report_type(frm); | |||
}, | |||
ref_doctype: function(frm) { | |||
@@ -47,7 +47,7 @@ def query_doctypes(doctype, txt, searchfield, start, page_len, filters): | |||
user = filters.get("user") | |||
user_perms = frappe.utils.user.UserPermissions(user) | |||
user_perms.build_permissions() | |||
can_read = user_perms.can_read | |||
can_read = user_perms.can_read # Does not include child tables | |||
single_doctypes = [d[0] for d in frappe.db.get_values("DocType", {"issingle": 1})] | |||
@@ -30,6 +30,7 @@ | |||
"mandatory_depends_on", | |||
"read_only_depends_on", | |||
"properties", | |||
"non_negative", | |||
"reqd", | |||
"unique", | |||
"read_only", | |||
@@ -403,13 +404,20 @@ | |||
"fieldname": "hide_border", | |||
"fieldtype": "Check", | |||
"label": "Hide Border" | |||
}, | |||
{ | |||
"default": "0", | |||
"depends_on": "eval:in_list([\"Int\", \"Float\", \"Currency\"], doc.fieldtype)", | |||
"fieldname": "non_negative", | |||
"fieldtype": "Check", | |||
"label": "Non Negative" | |||
} | |||
], | |||
"icon": "fa fa-glass", | |||
"idx": 1, | |||
"index_web_pages_for_search": 1, | |||
"links": [], | |||
"modified": "2020-08-28 11:28:44.377753", | |||
"modified": "2020-10-29 06:14:43.073329", | |||
"modified_by": "Administrator", | |||
"module": "Custom", | |||
"name": "Custom Field", | |||
@@ -488,6 +488,7 @@ docfield_properties = { | |||
'permlevel': 'Int', | |||
'width': 'Data', | |||
'print_width': 'Data', | |||
'non_negative': 'Check', | |||
'reqd': 'Check', | |||
'unique': 'Check', | |||
'ignore_user_permissions': 'Check', | |||
@@ -11,6 +11,7 @@ | |||
"label", | |||
"fieldtype", | |||
"fieldname", | |||
"non_negative", | |||
"reqd", | |||
"unique", | |||
"in_list_view", | |||
@@ -414,13 +415,20 @@ | |||
"fieldname": "hide_border", | |||
"fieldtype": "Check", | |||
"label": "Hide Border" | |||
}, | |||
{ | |||
"default": "0", | |||
"depends_on": "eval:in_list([\"Int\", \"Float\", \"Currency\"], doc.fieldtype)", | |||
"fieldname": "non_negative", | |||
"fieldtype": "Check", | |||
"label": "Non Negative" | |||
} | |||
], | |||
"idx": 1, | |||
"index_web_pages_for_search": 1, | |||
"istable": 1, | |||
"links": [], | |||
"modified": "2020-09-24 14:05:31.093927", | |||
"modified": "2020-10-29 06:11:57.661039", | |||
"modified_by": "Administrator", | |||
"module": "Custom", | |||
"name": "Customize Form Field", | |||
@@ -2,12 +2,19 @@ | |||
// For license information, please see license.txt | |||
frappe.ui.form.on('Notification Settings', { | |||
onload: () => { | |||
onload: (frm) => { | |||
frappe.breadcrumbs.add({ | |||
label: __('Settings'), | |||
route: '#modules/Settings', | |||
type: 'Custom' | |||
}); | |||
frm.set_query('subscribed_documents', () => { | |||
return { | |||
filters: { | |||
istable: 0 | |||
} | |||
}; | |||
}); | |||
}, | |||
refresh: (frm) => { | |||
@@ -22,68 +22,52 @@ | |||
"default": "1", | |||
"fieldname": "enabled", | |||
"fieldtype": "Check", | |||
"label": "Enabled", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Enabled" | |||
}, | |||
{ | |||
"fieldname": "subscribed_documents", | |||
"fieldtype": "Table MultiSelect", | |||
"label": "Subscribed Documents", | |||
"options": "Notification Subscribed Document", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Open Documents", | |||
"options": "Notification Subscribed Document" | |||
}, | |||
{ | |||
"fieldname": "column_break_3", | |||
"fieldtype": "Section Break", | |||
"label": "Email Settings", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Email Settings" | |||
}, | |||
{ | |||
"default": "1", | |||
"fieldname": "enable_email_notifications", | |||
"fieldtype": "Check", | |||
"label": "Enable Email Notifications", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Enable Email Notifications" | |||
}, | |||
{ | |||
"default": "1", | |||
"depends_on": "enable_email_notifications", | |||
"fieldname": "enable_email_mention", | |||
"fieldtype": "Check", | |||
"label": "Mentions", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Mentions" | |||
}, | |||
{ | |||
"default": "1", | |||
"depends_on": "enable_email_notifications", | |||
"fieldname": "enable_email_assignment", | |||
"fieldtype": "Check", | |||
"label": "Assignments", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Assignments" | |||
}, | |||
{ | |||
"default": "1", | |||
"depends_on": "enable_email_notifications", | |||
"fieldname": "enable_email_energy_point", | |||
"fieldtype": "Check", | |||
"label": "Energy Points", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Energy Points" | |||
}, | |||
{ | |||
"default": "1", | |||
"depends_on": "enable_email_notifications", | |||
"fieldname": "enable_email_share", | |||
"fieldtype": "Check", | |||
"label": "Document Share", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Document Share" | |||
}, | |||
{ | |||
"default": "__user", | |||
@@ -92,23 +76,20 @@ | |||
"hidden": 1, | |||
"label": "User", | |||
"options": "User", | |||
"read_only": 1, | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"read_only": 1 | |||
}, | |||
{ | |||
"default": "0", | |||
"fieldname": "seen", | |||
"fieldtype": "Check", | |||
"hidden": 1, | |||
"label": "Seen", | |||
"show_days": 1, | |||
"show_seconds": 1 | |||
"label": "Seen" | |||
} | |||
], | |||
"in_create": 1, | |||
"index_web_pages_for_search": 1, | |||
"links": [], | |||
"modified": "2020-05-31 22:16:40.798019", | |||
"modified": "2020-11-04 12:54:57.989317", | |||
"modified_by": "Administrator", | |||
"module": "Desk", | |||
"name": "Notification Settings", | |||
@@ -76,6 +76,7 @@ class UnknownDomainError(Exception): pass | |||
class MappingMismatchError(ValidationError): pass | |||
class InvalidStatusError(ValidationError): pass | |||
class MandatoryError(ValidationError): pass | |||
class NonNegativeError(ValidationError): pass | |||
class InvalidSignatureError(ValidationError): pass | |||
class RateLimitExceededError(ValidationError): pass | |||
class CannotChangeConstantError(ValidationError): pass | |||
@@ -1,345 +1,113 @@ | |||
{ | |||
"allow_copy": 0, | |||
"allow_guest_to_view": 0, | |||
"actions": [], | |||
"allow_import": 1, | |||
"allow_rename": 1, | |||
"autoname": "field:currency_name", | |||
"beta": 0, | |||
"creation": "2013-01-28 10:06:02", | |||
"custom": 0, | |||
"description": "**Currency** Master", | |||
"docstatus": 0, | |||
"doctype": "DocType", | |||
"document_type": "Setup", | |||
"editable_grid": 0, | |||
"engine": "InnoDB", | |||
"field_order": [ | |||
"currency_name", | |||
"enabled", | |||
"fraction", | |||
"fraction_units", | |||
"smallest_currency_fraction_value", | |||
"symbol", | |||
"number_format" | |||
], | |||
"fields": [ | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"fieldname": "currency_name", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Currency Name", | |||
"length": 0, | |||
"no_copy": 0, | |||
"oldfieldname": "currency_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, | |||
"translatable": 0, | |||
"unique": 1 | |||
}, | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"default": "0", | |||
"fieldname": "enabled", | |||
"fieldtype": "Check", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 1, | |||
"in_standard_filter": 0, | |||
"label": "Enabled", | |||
"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, | |||
"translatable": 0, | |||
"unique": 0 | |||
"label": "Enabled" | |||
}, | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "Sub-currency. For e.g. \"Cent\"", | |||
"fieldname": "fraction", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 1, | |||
"in_standard_filter": 0, | |||
"label": "Fraction", | |||
"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, | |||
"translatable": 0, | |||
"unique": 0 | |||
"label": "Fraction" | |||
}, | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "1 Currency = [?] Fraction\nFor e.g. 1 USD = 100 Cent", | |||
"fieldname": "fraction_units", | |||
"fieldtype": "Int", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 1, | |||
"in_standard_filter": 0, | |||
"label": "Fraction Units", | |||
"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, | |||
"translatable": 0, | |||
"unique": 0 | |||
"label": "Fraction Units" | |||
}, | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "Smallest circulating fraction unit (coin). For e.g. 1 cent for USD and it should be entered as 0.01", | |||
"fieldname": "smallest_currency_fraction_value", | |||
"fieldtype": "Currency", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 0, | |||
"in_standard_filter": 0, | |||
"label": "Smallest Currency Fraction Value", | |||
"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, | |||
"translatable": 0, | |||
"unique": 0 | |||
"non_negative": 1 | |||
}, | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "A symbol for this currency. For e.g. $", | |||
"fieldname": "symbol", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 1, | |||
"in_standard_filter": 0, | |||
"label": "Symbol", | |||
"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, | |||
"translatable": 0, | |||
"unique": 0 | |||
"label": "Symbol" | |||
}, | |||
{ | |||
"allow_bulk_edit": 0, | |||
"allow_in_quick_entry": 0, | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"columns": 0, | |||
"description": "How should this currency be formatted? If not set, will use system defaults", | |||
"fieldname": "number_format", | |||
"fieldtype": "Select", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_global_search": 0, | |||
"in_list_view": 1, | |||
"in_standard_filter": 0, | |||
"label": "Number Format", | |||
"length": 0, | |||
"no_copy": 0, | |||
"options": "\n#,###.##\n#.###,##\n# ###.##\n# ###,##\n#'###.##\n#, ###.##\n#,##,###.##\n#,###.###\n#.###\n#,###", | |||
"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, | |||
"translatable": 0, | |||
"unique": 0 | |||
"options": "\n#,###.##\n#.###,##\n# ###.##\n# ###,##\n#'###.##\n#, ###.##\n#,##,###.##\n#,###.###\n#.###\n#,###" | |||
} | |||
], | |||
"has_web_view": 0, | |||
"hide_heading": 0, | |||
"hide_toolbar": 0, | |||
"icon": "fa fa-bitcoin", | |||
"idx": 1, | |||
"image_view": 0, | |||
"in_create": 0, | |||
"is_submittable": 0, | |||
"issingle": 0, | |||
"istable": 0, | |||
"max_attachments": 0, | |||
"modified": "2018-08-29 06:37:19.908254", | |||
"index_web_pages_for_search": 1, | |||
"links": [], | |||
"modified": "2020-10-29 06:33:12.879978", | |||
"modified_by": "Administrator", | |||
"module": "Geo", | |||
"name": "Currency", | |||
"owner": "Administrator", | |||
"permissions": [ | |||
{ | |||
"amend": 0, | |||
"cancel": 0, | |||
"create": 1, | |||
"delete": 1, | |||
"email": 1, | |||
"export": 1, | |||
"if_owner": 0, | |||
"import": 1, | |||
"permlevel": 0, | |||
"print": 1, | |||
"read": 1, | |||
"report": 1, | |||
"role": "System Manager", | |||
"set_user_permissions": 0, | |||
"share": 1, | |||
"submit": 0, | |||
"write": 1 | |||
}, | |||
{ | |||
"amend": 0, | |||
"cancel": 0, | |||
"create": 0, | |||
"delete": 0, | |||
"email": 0, | |||
"export": 0, | |||
"if_owner": 0, | |||
"import": 0, | |||
"permlevel": 0, | |||
"print": 0, | |||
"read": 1, | |||
"report": 0, | |||
"role": "Accounts User", | |||
"set_user_permissions": 0, | |||
"share": 0, | |||
"submit": 0, | |||
"write": 0 | |||
"role": "Accounts User" | |||
}, | |||
{ | |||
"amend": 0, | |||
"cancel": 0, | |||
"create": 0, | |||
"delete": 0, | |||
"email": 0, | |||
"export": 0, | |||
"if_owner": 0, | |||
"import": 0, | |||
"permlevel": 0, | |||
"print": 0, | |||
"read": 1, | |||
"report": 0, | |||
"role": "Sales User", | |||
"set_user_permissions": 0, | |||
"share": 0, | |||
"submit": 0, | |||
"write": 0 | |||
"role": "Sales User" | |||
}, | |||
{ | |||
"amend": 0, | |||
"cancel": 0, | |||
"create": 0, | |||
"delete": 0, | |||
"email": 0, | |||
"export": 0, | |||
"if_owner": 0, | |||
"import": 0, | |||
"permlevel": 0, | |||
"print": 0, | |||
"read": 1, | |||
"report": 0, | |||
"role": "Purchase User", | |||
"set_user_permissions": 0, | |||
"share": 0, | |||
"submit": 0, | |||
"write": 0 | |||
"role": "Purchase User" | |||
} | |||
], | |||
"quick_entry": 0, | |||
"read_only": 0, | |||
"read_only_onload": 0, | |||
"show_name_in_global_search": 0, | |||
"sort_field": "modified", | |||
"sort_order": "DESC", | |||
"track_changes": 1, | |||
"track_seen": 0, | |||
"track_views": 0 | |||
"track_changes": 1 | |||
} |
@@ -493,6 +493,7 @@ class Document(BaseDocument): | |||
self._validate_mandatory() | |||
self._validate_data_fields() | |||
self._validate_selects() | |||
self._validate_non_negative() | |||
self._validate_length() | |||
self._extract_images_from_text_editor() | |||
self._sanitize_content() | |||
@@ -503,6 +504,7 @@ class Document(BaseDocument): | |||
for d in children: | |||
d._validate_data_fields() | |||
d._validate_selects() | |||
d._validate_non_negative() | |||
d._validate_length() | |||
d._extract_images_from_text_editor() | |||
d._sanitize_content() | |||
@@ -514,6 +516,21 @@ class Document(BaseDocument): | |||
else: | |||
self.validate_set_only_once() | |||
def _validate_non_negative(self): | |||
def get_msg(df): | |||
if self.parentfield: | |||
return "{} {} #{}: {} {}".format(frappe.bold(_(self.doctype)), | |||
_("Row"), self.idx, _("Value cannot be negative for"), frappe.bold(_(df.label))) | |||
else: | |||
return _("Value cannot be negative for {0}: {1}").format(_(df.parent), frappe.bold(_(df.label))) | |||
for df in self.meta.get('fields', {'non_negative': ('=', 1), | |||
'fieldtype': ('in', ['Int', 'Float', 'Currency'])}): | |||
if flt(self.get(df.fieldname)) < 0: | |||
msg = get_msg(df) | |||
frappe.throw(msg, frappe.NonNegativeError, title=_("Negative Value")) | |||
def validate_workflow(self): | |||
"""Validate if the workflow transition is valid""" | |||
if frappe.flags.in_install == 'frappe': return | |||
@@ -314,3 +314,5 @@ execute:frappe.db.set_value('Website Settings', 'Website Settings', {'navbar_tem | |||
frappe.patches.v13_0.delete_event_producer_and_consumer_keys | |||
frappe.patches.v13_0.web_template_set_module #2020-10-05 | |||
frappe.patches.v13_0.remove_custom_link | |||
execute:frappe.delete_doc("DocType", "Footer Item") | |||
frappe.patches.v13_0.replace_field_target_with_open_in_new_tab |
@@ -0,0 +1,11 @@ | |||
import frappe | |||
def execute(): | |||
doctype = "Top Bar Item" | |||
if not frappe.db.table_exists(doctype) \ | |||
or not frappe.db.has_column(doctype, "target"): | |||
return | |||
frappe.reload_doc("website", "doctype", "top_bar_item") | |||
frappe.db.set_value(doctype, {"target": 'target = "_blank"'}, 'open_in_new_tab', 1) |
@@ -261,7 +261,7 @@ frappe.ui.form.Form = class FrappeForm { | |||
cur_frm = this; | |||
if(this.docname) { // document to show | |||
this.save_disabled = false; | |||
// set the doc | |||
this.doc = frappe.get_doc(this.doctype, this.docname); | |||
@@ -10,7 +10,12 @@ frappe.views.GanttView = class GanttView extends frappe.views.ListView { | |||
.then(() => { | |||
this.page_title = this.page_title + ' ' + __('Gantt'); | |||
this.calendar_settings = frappe.views.calendar[this.doctype] || {}; | |||
if(this.calendar_settings.order_by) { | |||
if (typeof this.calendar_settings.gantt == 'object') { | |||
Object.assign(this.calendar_settings, this.calendar_settings.gantt); | |||
} | |||
if (this.calendar_settings.order_by) { | |||
this.sort_by = this.calendar_settings.order_by; | |||
this.sort_order = 'asc'; | |||
} else { | |||
@@ -1043,7 +1043,11 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { | |||
// applied to Float, Currency fields, needed only for currency formatting. | |||
// make first data column have value 'Total' | |||
let index = 1; | |||
if (this.datatable && this.datatable.options.checkboxColumn) index = 2; | |||
if (this.report_settings.get_datatable_options) { | |||
let datatable = this.report_settings.get_datatable_options({}); | |||
if (datatable && datatable.checkboxColumn) index = 2; | |||
} | |||
if (column.colIndex === index && !value) { | |||
value = "Total"; | |||
@@ -150,7 +150,12 @@ class ShortcutDialog extends WidgetDialog { | |||
onchange: () => { | |||
if (this.dialog.get_value("type") == "DocType") { | |||
this.dialog.fields_dict.link_to.get_query = () => { | |||
return { filters: { istable: false } }; | |||
return { | |||
query: "frappe.core.report.permitted_documents_for_user.permitted_documents_for_user.query_doctypes", | |||
filters: { | |||
user: frappe.session.user | |||
} | |||
}; | |||
}; | |||
} else { | |||
this.dialog.fields_dict.link_to.get_query = null; | |||
@@ -15,7 +15,8 @@ | |||
<ul class="footer-group-links list-unstyled"> | |||
{%- for child in group.child_items -%} | |||
<li class="footer-child-item" data-label="{{ child.label }}"> | |||
<a href="{{ child.url | abs_url }}" {% if child.target %} target="_blank" {% endif %} rel="noreferrer"> | |||
<a href="{{ child.url | abs_url }}" | |||
{% if child.open_in_new_tab %} target="_blank" {% endif %} rel="noreferrer"> | |||
{%- if child.icon -%} | |||
<img src="{{ child.icon }}" alt="{{ child.label }}"> | |||
{%- else -%} | |||
@@ -1,5 +1,5 @@ | |||
{% macro footer_link(item) %} | |||
<a href="{{ item.url | abs_url }}" {{ item.target }} class="footer-link" rel="noreferrer"> | |||
<a href="{{ item.url | abs_url }}" {% if item.open_in_new_tab %} target="_blank" {% endif %} class="footer-link" rel="noreferrer"> | |||
{%- if item.icon -%} | |||
<img src="{{ item.icon }}" alt="{{ item.label }}"> | |||
{%- else -%} | |||
@@ -4,7 +4,7 @@ | |||
<li {% if child.label %}data-label="{{ child.label }}" {% endif %} | |||
class="{% if child.class %} {{ child.class }} {% endif %} logged-in" > | |||
{%- if child.url -%} | |||
<a href="{{ child.url | abs_url }}" {{ child.target or '' }} | |||
<a href="{{ child.url | abs_url }}" {% if child.open_in_new_tab %} target="_blank" {% endif %} | |||
rel="nofollow"> | |||
{{ child.label }} | |||
</a> | |||
@@ -35,13 +35,13 @@ | |||
{% if parent %} | |||
<li class="nav-item"> | |||
<a class="nav-link" href="{{ (item.url or '')|abs_url }}" | |||
{{ item.target or ''}}> | |||
{% if item.open_in_new_tab %} target="_blank" {% endif %}> | |||
{{ item.label }} | |||
</a> | |||
</li> | |||
{% else %} | |||
<a class="dropdown-item" href="{{ (item.url or '') | abs_url }}" | |||
{{ item.target or '' }}> | |||
{% if item.open_in_new_tab %} target="_blank" {% endif %}> | |||
{{ item.label }} | |||
</a> | |||
{% endif %} | |||
@@ -11,7 +11,7 @@ | |||
<ul class="dropdown-menu dropdown-menu-right" role="menu"> | |||
{%- for child in post_login -%} | |||
{%- if child.url -%} | |||
<a class="dropdown-item" href="{{ child.url | abs_url }}" {{ child.target or '' }} rel="nofollow"> | |||
<a class="dropdown-item" href="{{ child.url | abs_url }}" {% if child.open_in_new_tab %} target="_blank" {% endif %} rel="nofollow"> | |||
{{ child.label }} | |||
</a> | |||
{%- endif -%} | |||
@@ -288,4 +288,21 @@ class TestDocument(unittest.TestCase): | |||
self.assertEqual(merged_todo_doc.priority, second_todo_doc.priority) | |||
for docname in available_documents: | |||
frappe.delete_doc(doctype, docname) | |||
frappe.delete_doc(doctype, docname) | |||
def test_non_negative_check(self): | |||
frappe.delete_doc_if_exists("Currency", "Frappe Coin", 1) | |||
d = frappe.get_doc({ | |||
'doctype': 'Currency', | |||
'currency_name': 'Frappe Coin', | |||
'smallest_currency_fraction_value': -1 | |||
}) | |||
self.assertRaises(frappe.NonNegativeError, d.insert) | |||
d.set('smallest_currency_fraction_value', 1) | |||
d.insert() | |||
self.assertEqual(frappe.db.get_value("Currency", d.name), d.name) | |||
frappe.delete_doc_if_exists("Currency", "Frappe Coin", 1) |
@@ -1,146 +0,0 @@ | |||
{ | |||
"allow_copy": 0, | |||
"allow_import": 0, | |||
"allow_rename": 0, | |||
"beta": 0, | |||
"creation": "2016-04-12 18:40:16.315024", | |||
"custom": 0, | |||
"docstatus": 0, | |||
"doctype": "DocType", | |||
"document_type": "Other", | |||
"editable_grid": 1, | |||
"fields": [ | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"fieldname": "label", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 1, | |||
"label": "Label", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"print_width": "120px", | |||
"read_only": 0, | |||
"report_hide": 0, | |||
"reqd": 1, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0, | |||
"width": "120px" | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "", | |||
"fieldname": "group_label", | |||
"fieldtype": "Select", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 1, | |||
"label": "Group Label", | |||
"length": 0, | |||
"no_copy": 0, | |||
"options": "\nCompany\nContact\nPolicy", | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "Link to the page you want to open. Leave blank if you want to make it a group parent.", | |||
"fieldname": "url", | |||
"fieldtype": "Data", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 1, | |||
"label": "URL", | |||
"length": 0, | |||
"no_copy": 0, | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"print_width": "200px", | |||
"read_only": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0, | |||
"width": "200px" | |||
}, | |||
{ | |||
"allow_on_submit": 0, | |||
"bold": 0, | |||
"collapsible": 0, | |||
"description": "Select target = \"_blank\" to open in a new page.", | |||
"fieldname": "target", | |||
"fieldtype": "Select", | |||
"hidden": 0, | |||
"ignore_user_permissions": 0, | |||
"ignore_xss_filter": 0, | |||
"in_filter": 0, | |||
"in_list_view": 0, | |||
"label": "Target", | |||
"length": 0, | |||
"no_copy": 0, | |||
"options": "\ntarget = \"_blank\"", | |||
"permlevel": 0, | |||
"precision": "", | |||
"print_hide": 0, | |||
"print_hide_if_no_value": 0, | |||
"read_only": 0, | |||
"report_hide": 0, | |||
"reqd": 0, | |||
"search_index": 0, | |||
"set_only_once": 0, | |||
"unique": 0 | |||
} | |||
], | |||
"hide_heading": 0, | |||
"hide_toolbar": 0, | |||
"idx": 0, | |||
"image_view": 0, | |||
"in_create": 0, | |||
"is_submittable": 0, | |||
"issingle": 0, | |||
"istable": 1, | |||
"max_attachments": 0, | |||
"modified": "2016-07-11 03:28:00.573336", | |||
"modified_by": "Administrator", | |||
"module": "Website", | |||
"name": "Footer Item", | |||
"name_case": "", | |||
"owner": "Administrator", | |||
"permissions": [], | |||
"quick_entry": 0, | |||
"read_only": 0, | |||
"read_only_onload": 0, | |||
"sort_field": "modified", | |||
"sort_order": "ASC", | |||
"track_seen": 0 | |||
} |
@@ -1,10 +0,0 @@ | |||
# -*- 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 FooterItem(Document): | |||
pass |
@@ -8,7 +8,7 @@ | |||
"field_order": [ | |||
"label", | |||
"url", | |||
"target", | |||
"open_in_new_tab", | |||
"right", | |||
"column_break_5", | |||
"parent_label", | |||
@@ -40,19 +40,11 @@ | |||
"print_width": "200px", | |||
"width": "200px" | |||
}, | |||
{ | |||
"description": "Select target = \"_blank\" to open in a new page.", | |||
"fieldname": "target", | |||
"fieldtype": "Select", | |||
"label": "Target", | |||
"options": "\ntarget = \"_blank\"" | |||
}, | |||
{ | |||
"default": "1", | |||
"description": "For top bar", | |||
"fieldname": "right", | |||
"fieldtype": "Check", | |||
"label": "Right" | |||
"label": "Align Right" | |||
}, | |||
{ | |||
"fieldname": "column_break_5", | |||
@@ -63,12 +55,20 @@ | |||
"fieldname": "icon", | |||
"fieldtype": "Attach Image", | |||
"label": "Icon" | |||
}, | |||
{ | |||
"default": "0", | |||
"depends_on": "eval:doc.url", | |||
"fieldname": "open_in_new_tab", | |||
"fieldtype": "Check", | |||
"label": "Open URL in a New Tab" | |||
} | |||
], | |||
"idx": 1, | |||
"index_web_pages_for_search": 1, | |||
"istable": 1, | |||
"links": [], | |||
"modified": "2020-05-11 06:12:13.191644", | |||
"modified": "2020-10-26 20:59:42.142208", | |||
"modified_by": "Administrator", | |||
"module": "Website", | |||
"name": "Top Bar Item", | |||
@@ -2247,9 +2247,9 @@ fragment-cache@^0.2.1: | |||
map-cache "^0.2.2" | |||
frappe-charts@^1.5.1: | |||
version "1.5.1" | |||
resolved "https://registry.yarnpkg.com/frappe-charts/-/frappe-charts-1.5.1.tgz#77b9e61400b1657d4ca2eb2202053e3a4d18d54b" | |||
integrity sha512-Cvj6IyDkiH6LKw558A8syJUmkQSdNVnfC+WAzDaAtOfs+u2nST6HExA6JUZMaHU4+VJhC2PWwyRjRNw3B5FaUQ== | |||
version "1.5.3" | |||
resolved "https://registry.yarnpkg.com/frappe-charts/-/frappe-charts-1.5.3.tgz#0dcb86ea774fa7a3e1b79221e958d29701dfff04" | |||
integrity sha512-VS5XVxek41ea8mVzetyFF3avNefiwGDcDSDJuHrZyJXgbqiTSXLoqlPFoMqTzuzRm1g+o6TXs+A7wLtVp3Vt0g== | |||
frappe-datatable@^1.15.3: | |||
version "1.15.3" | |||