fix: show cards created by user

This commit is contained in:
prssanna 2020-04-19 01:08:45 +05:30
parent e7a163168b
commit 759f76f9cd
2 changed files with 10 additions and 6 deletions

View file

@ -45,4 +45,8 @@ def create_number_card(args):
doc.is_standard = 1
doc.update(args)
doc.insert(ignore_permissions=True)
return doc
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)

View file

@ -277,9 +277,9 @@ class NumberCardDialog extends WidgetDialog {
options: 'Number Card',
get_query: () => {
return {
'query': 'frappe.desk.doctype.number_card.number_card.get_cards_for_user',
filters: {
document_type: this.document_type,
is_standard: 1
document_type: this.document_type,
}
};
},
@ -360,16 +360,16 @@ class NumberCardDialog extends WidgetDialog {
if (this.default_values['doctype']) {
this.document_type = this.default_values['doctype'];
this.setup_filter(this.default_values['doctype']);
this.set_aggregate_function_fields(this.dialog.get_values());
this.set_aggregate_function_fields();
} else {
this.show_field('document_type');
}
}
}
set_aggregate_function_fields(values) {
set_aggregate_function_fields() {
let aggregate_function_fields = [];
if (values.function !== 'Count' && this.document_type) {
if (this.document_type) {
frappe.get_meta(this.document_type).fields.map(df => {
if (frappe.model.numeric_fieldtypes.includes(df.fieldtype)) {
aggregate_function_fields.push({label: df.label, value: df.fieldname});