mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
feat: validate multiple links
This commit is contained in:
@@ -10,3 +10,17 @@ class PartyLink(Document):
|
|||||||
if self.primary_role not in ['Customer', 'Supplier']:
|
if self.primary_role not in ['Customer', 'Supplier']:
|
||||||
frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."),
|
frappe.throw(_("Allowed primary roles are 'Customer' and 'Supplier'. Please select one of these roles only."),
|
||||||
title=_("Invalid Primary Role"))
|
title=_("Invalid Primary Role"))
|
||||||
|
|
||||||
|
existing_party_link = frappe.get_all('Party Link', {
|
||||||
|
'primary_party': self.secondary_party
|
||||||
|
}, pluck="primary_role")
|
||||||
|
if existing_party_link:
|
||||||
|
frappe.throw(_('{} {} is already linked with another {}')
|
||||||
|
.format(self.secondary_role, self.secondary_party, existing_party_link[0]))
|
||||||
|
|
||||||
|
existing_party_link = frappe.get_all('Party Link', {
|
||||||
|
'secondary_party': self.primary_party
|
||||||
|
}, pluck="primary_role")
|
||||||
|
if existing_party_link:
|
||||||
|
frappe.throw(_('{} {} is already linked with another {}')
|
||||||
|
.format(self.primary_role, self.primary_party, existing_party_link[0]))
|
||||||
|
|||||||
Reference in New Issue
Block a user