fix: existing party link validation (#29159)
This commit is contained in:
parent
ac816f4fed
commit
fbd706f232
@ -2,7 +2,7 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe import _, bold
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
@ -12,6 +12,17 @@ class PartyLink(Document):
|
||||
frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."),
|
||||
title=_("Invalid Primary Role"))
|
||||
|
||||
existing_party_link = frappe.get_all('Party Link', {
|
||||
'primary_party': self.primary_party,
|
||||
'secondary_party': self.secondary_party
|
||||
}, pluck="primary_role")
|
||||
if existing_party_link:
|
||||
frappe.throw(_('{} {} is already linked with {} {}')
|
||||
.format(
|
||||
self.primary_role, bold(self.primary_party),
|
||||
self.secondary_role, bold(self.secondary_party)
|
||||
))
|
||||
|
||||
existing_party_link = frappe.get_all('Party Link', {
|
||||
'primary_party': self.secondary_party
|
||||
}, pluck="primary_role")
|
||||
|
Loading…
Reference in New Issue
Block a user