fix: Membership - allow system users to create membership for existing Members
This commit is contained in:
parent
71ede099ea
commit
f01bf9048d
@ -12,20 +12,21 @@ import erpnext
|
|||||||
|
|
||||||
class Membership(Document):
|
class Membership(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
member_name = frappe.get_value('Member', dict(email=frappe.session.user))
|
if not self.member or not frappe.db.exists("Member", self.member):
|
||||||
|
member_name = frappe.get_value('Member', dict(email=frappe.session.user))
|
||||||
|
|
||||||
if not member_name:
|
if not member_name:
|
||||||
user = frappe.get_doc('User', frappe.session.user)
|
user = frappe.get_doc('User', frappe.session.user)
|
||||||
member = frappe.get_doc(dict(
|
member = frappe.get_doc(dict(
|
||||||
doctype='Member',
|
doctype='Member',
|
||||||
email=frappe.session.user,
|
email=frappe.session.user,
|
||||||
membership_type=self.membership_type,
|
membership_type=self.membership_type,
|
||||||
member_name=user.get_fullname()
|
member_name=user.get_fullname()
|
||||||
)).insert(ignore_permissions=True)
|
)).insert(ignore_permissions=True)
|
||||||
member_name = member.name
|
member_name = member.name
|
||||||
|
|
||||||
if self.get("__islocal"):
|
if self.get("__islocal"):
|
||||||
self.member = member_name
|
self.member = member_name
|
||||||
|
|
||||||
# get last membership (if active)
|
# get last membership (if active)
|
||||||
last_membership = erpnext.get_last_membership()
|
last_membership = erpnext.get_last_membership()
|
||||||
|
Loading…
Reference in New Issue
Block a user