Merge pull request #33402 from ruthra-kumar/hidden_party_detail_fields_for_better_handling_of_permission
refactor: Customer and Supplier Ledger summary will have hidden fields for better handling of user permission
This commit is contained in:
commit
a31e9d3afe
@ -26,6 +26,7 @@ class PartyLedgerSummaryReport(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.get_gl_entries()
|
self.get_gl_entries()
|
||||||
|
self.get_additional_columns()
|
||||||
self.get_return_invoices()
|
self.get_return_invoices()
|
||||||
self.get_party_adjustment_amounts()
|
self.get_party_adjustment_amounts()
|
||||||
|
|
||||||
@ -33,6 +34,42 @@ class PartyLedgerSummaryReport(object):
|
|||||||
data = self.get_data()
|
data = self.get_data()
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
|
def get_additional_columns(self):
|
||||||
|
"""
|
||||||
|
Additional Columns for 'User Permission' based access control
|
||||||
|
"""
|
||||||
|
from frappe import qb
|
||||||
|
|
||||||
|
if self.filters.party_type == "Customer":
|
||||||
|
self.territories = frappe._dict({})
|
||||||
|
self.customer_group = frappe._dict({})
|
||||||
|
|
||||||
|
customer = qb.DocType("Customer")
|
||||||
|
result = (
|
||||||
|
frappe.qb.from_(customer)
|
||||||
|
.select(
|
||||||
|
customer.name, customer.territory, customer.customer_group, customer.default_sales_partner
|
||||||
|
)
|
||||||
|
.where((customer.disabled == 0))
|
||||||
|
.run(as_dict=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
for x in result:
|
||||||
|
self.territories[x.name] = x.territory
|
||||||
|
self.customer_group[x.name] = x.customer_group
|
||||||
|
else:
|
||||||
|
self.supplier_group = frappe._dict({})
|
||||||
|
supplier = qb.DocType("Supplier")
|
||||||
|
result = (
|
||||||
|
frappe.qb.from_(supplier)
|
||||||
|
.select(supplier.name, supplier.supplier_group)
|
||||||
|
.where((supplier.disabled == 0))
|
||||||
|
.run(as_dict=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
for x in result:
|
||||||
|
self.supplier_group[x.name] = x.supplier_group
|
||||||
|
|
||||||
def get_columns(self):
|
def get_columns(self):
|
||||||
columns = [
|
columns = [
|
||||||
{
|
{
|
||||||
@ -116,6 +153,35 @@ class PartyLedgerSummaryReport(object):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Hidden columns for handling 'User Permissions'
|
||||||
|
if self.filters.party_type == "Customer":
|
||||||
|
columns += [
|
||||||
|
{
|
||||||
|
"label": _("Territory"),
|
||||||
|
"fieldname": "territory",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Territory",
|
||||||
|
"hidden": 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Customer Group"),
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Customer Group",
|
||||||
|
"hidden": 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
columns += [
|
||||||
|
{
|
||||||
|
"label": _("Supplier Group"),
|
||||||
|
"fieldname": "supplier_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Supplier Group",
|
||||||
|
"hidden": 1,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
return columns
|
return columns
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
@ -143,6 +209,12 @@ class PartyLedgerSummaryReport(object):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.filters.party_type == "Customer":
|
||||||
|
self.party_data[gle.party].update({"territory": self.territories.get(gle.party)})
|
||||||
|
self.party_data[gle.party].update({"customer_group": self.customer_group.get(gle.party)})
|
||||||
|
else:
|
||||||
|
self.party_data[gle.party].update({"supplier_group": self.supplier_group.get(gle.party)})
|
||||||
|
|
||||||
amount = gle.get(invoice_dr_or_cr) - gle.get(reverse_dr_or_cr)
|
amount = gle.get(invoice_dr_or_cr) - gle.get(reverse_dr_or_cr)
|
||||||
self.party_data[gle.party].closing_balance += amount
|
self.party_data[gle.party].closing_balance += amount
|
||||||
|
|
||||||
|
@ -63,24 +63,6 @@ frappe.query_reports["Supplier Ledger Summary"] = {
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Payment Terms Template"
|
"options": "Payment Terms Template"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname":"territory",
|
|
||||||
"label": __("Territory"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Territory"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname":"sales_partner",
|
|
||||||
"label": __("Sales Partner"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Sales Partner"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname":"sales_person",
|
|
||||||
"label": __("Sales Person"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Sales Person"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname":"tax_id",
|
"fieldname":"tax_id",
|
||||||
"label": __("Tax Id"),
|
"label": __("Tax Id"),
|
||||||
|
@ -139,10 +139,11 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-02-08 17:01:52.162202",
|
"modified": "2022-12-24 11:15:17.142746",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Customer Group",
|
"name": "Customer Group",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
"nsm_parent_field": "parent_customer_group",
|
"nsm_parent_field": "parent_customer_group",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
@ -198,10 +199,19 @@
|
|||||||
"role": "Customer",
|
"role": "Customer",
|
||||||
"select": 1,
|
"select": 1,
|
||||||
"share": 1
|
"share": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"email": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"share": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"search_fields": "parent_customer_group",
|
"search_fields": "parent_customer_group",
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
@ -6,6 +6,7 @@
|
|||||||
"creation": "2013-01-10 16:34:24",
|
"creation": "2013-01-10 16:34:24",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "Setup",
|
"document_type": "Setup",
|
||||||
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"supplier_group_name",
|
"supplier_group_name",
|
||||||
"parent_supplier_group",
|
"parent_supplier_group",
|
||||||
@ -106,10 +107,11 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-03-18 18:10:49.228407",
|
"modified": "2022-12-24 11:16:12.486719",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Supplier Group",
|
"name": "Supplier Group",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
"nsm_parent_field": "parent_supplier_group",
|
"nsm_parent_field": "parent_supplier_group",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
@ -156,8 +158,18 @@
|
|||||||
"permlevel": 1,
|
"permlevel": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"role": "Purchase User"
|
"role": "Purchase User"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"email": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"share": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_order": "ASC"
|
"sort_field": "modified",
|
||||||
|
"sort_order": "ASC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
@ -123,11 +123,12 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_tree": 1,
|
"is_tree": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-02-08 17:10:03.767426",
|
"modified": "2022-12-24 11:16:39.964956",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "Territory",
|
"name": "Territory",
|
||||||
"name_case": "Title Case",
|
"name_case": "Title Case",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
"nsm_parent_field": "parent_territory",
|
"nsm_parent_field": "parent_territory",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
@ -175,10 +176,19 @@
|
|||||||
"role": "Customer",
|
"role": "Customer",
|
||||||
"select": 1,
|
"select": 1,
|
||||||
"share": 1
|
"share": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"email": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Accounts User",
|
||||||
|
"share": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"search_fields": "parent_territory,territory_manager",
|
"search_fields": "parent_territory,territory_manager",
|
||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user