mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
fix: prevent duplicate pos fields in pos settings (#45873)
fix: restrict duplicate pos fields in pos settings
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
@@ -22,4 +25,14 @@ class POSSettings(Document):
|
|||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
pass
|
self.validate_invoice_fields()
|
||||||
|
|
||||||
|
def validate_invoice_fields(self):
|
||||||
|
invoice_fields = [field.fieldname for field in self.invoice_fields]
|
||||||
|
duplicate_invoice_fields = {key for key, value in Counter(invoice_fields).items() if value > 1}
|
||||||
|
|
||||||
|
if len(duplicate_invoice_fields):
|
||||||
|
for field in duplicate_invoice_fields:
|
||||||
|
frappe.throw(
|
||||||
|
title=_("Duplicate POS Fields"), msg=_("'{0}' has been already added.").format(field)
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user