fix(patch): patch to set existing dashboard charts as standard

This commit is contained in:
prssanna 2020-04-19 02:35:24 +05:30
parent 759f76f9cd
commit f3db07fe01
4 changed files with 35 additions and 3 deletions

View file

@ -48,5 +48,9 @@ def create_number_card(args):
return doc
def get_cards_for_user(doctype, txt, searchfield, start, page_len, filters):
or_filters = {'creation': frappe.session.user, 'is_standard': 1}
return frappe.db.get_list('Number Card', fields=['name', 'label'], or_filters=or_filters, as_list = 1)
or_filters = {'owner': frappe.session.user, 'is_standard': 1}
return frappe.db.get_list('Number Card',
fields=['name', 'label'],
filters=filters,
or_filters=or_filters,
as_list = 1)

View file

@ -273,3 +273,4 @@ execute:frappe.delete_doc_if_exists('DocType', 'GCalendar Settings')
frappe.patches.v12_0.remove_parent_and_parenttype_from_print_formats
execute:from frappe.desk.page.setup_wizard.install_fixtures import update_genders;update_genders()
frappe.patches.v13_0.website_theme_custom_scss
frappe.patches.v13_0.set_existing_dashboard_charts_as_standard

View file

@ -0,0 +1,27 @@
import frappe
def execute():
if not frappe.db.table_exists('Dashboard Chart'):
return
users_with_permission = frappe.get_all(
"Has Role",
fields=["parent"],
filters={"role": ['in', ['System Manager', 'Dashboard Manager']], "parenttype": "User"},
distinct=True,
as_list=True
)
users = tuple(
[item if type(item) == str else item.encode('utf8') for sublist in users_with_permission for item in sublist]
)
frappe.db.sql("""
UPDATE
`tabDashboard Chart`
SET
`tabDashboard Chart`.`is_standard`=1
WHERE
`tabDashboard Chart`.owner in {users}
""".format(users=users)
)

View file

@ -329,7 +329,7 @@ class NumberCardDialog extends WidgetDialog {
fieldname: 'aggregate_function_based_on',
fieldtype: 'Select',
depends_on: "eval: doc.function !== 'Count'",
mandatory_depends_on: "eval: doc.function !== 'Count'"
mandatory_depends_on: 'eval: doc.function !== "Count" && doc.new_or_existing == "New Card"'
},
{
fieldtype: "Section Break",