feat: add party groups functionality to party specific item (backport #54988) (#55245)

Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
mergify[bot]
2026-05-25 12:38:44 +05:30
committed by GitHub
parent 7752f703d2
commit a618f4cca4
5 changed files with 53 additions and 7 deletions

View File

@@ -211,16 +211,28 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
if filters and isinstance(filters, dict):
if filters.get("customer") or filters.get("supplier"):
party_type = "Customer" if filters.get("customer") else "Supplier"
party = filters.get("customer") or filters.get("supplier")
group = "Customer Group" if filters.get("customer") else "Supplier Group"
item_rules_list = frappe.get_all(
"Party Specific Item",
filters={
"party": ["!=", party],
"party_type": "Customer" if filters.get("customer") else "Supplier",
"party_type": party_type,
},
fields=["restrict_based_on", "based_on_value"],
)
party_group_rules_list = frappe.get_all(
"Party Specific Item",
filters={"party_type": group},
fields=["party as party_group", "restrict_based_on", "based_on_value"],
)
current_party_group = frappe.get_value(party_type, party, frappe.scrub(group))
for rule in party_group_rules_list:
if current_party_group != rule.party_group:
item_rules_list.append(rule)
filters_dict = {}
for rule in item_rules_list:
if rule["restrict_based_on"] == "Item":