refactor: add meta as separate parameter

This commit is contained in:
Summayya 2021-11-25 20:25:04 +05:30
parent 435cf503fa
commit 4d2f9157ae
2 changed files with 4 additions and 4 deletions

View file

@ -1485,7 +1485,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
const doctype = this.doctype;
const items = [];
if (frappe.model.can_import(this.meta)) {
if (frappe.model.can_import(doctype, null, this.meta)) {
items.push({
label: __("Import"),
action: () =>

View file

@ -317,14 +317,14 @@ $.extend(frappe.model, {
return doc && doc.__last_sync_on && ((new Date() - doc.__last_sync_on)) < 5000;
},
can_import: function(doctype, frm) {
if (!doctype.allow_import) return false;
can_import: function(doctype, frm, meta=null) {
if (meta && !meta.allow_import) return false;
// system manager can always import
if (frappe.user_roles.includes("System Manager")) return true;
if (frm) return frm.perm[0].import===1;
return frappe.boot.user.can_import.indexOf(doctype.name)!==-1;
return frappe.boot.user.can_import.indexOf(doctype)!==-1;
},
can_export: function(doctype, frm) {