Merge pull request #15868 from ESS-LLP/fix-membership

fix: Membership - allow system users to create membership
This commit is contained in:
Shreya Shah 2018-11-01 10:54:32 +05:30 committed by GitHub
commit 9f931780a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,20 +12,21 @@ import erpnext
class Membership(Document):
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:
user = frappe.get_doc('User', frappe.session.user)
member = frappe.get_doc(dict(
doctype='Member',
email=frappe.session.user,
membership_type=self.membership_type,
member_name=user.get_fullname()
)).insert(ignore_permissions=True)
member_name = member.name
if not member_name:
user = frappe.get_doc('User', frappe.session.user)
member = frappe.get_doc(dict(
doctype='Member',
email=frappe.session.user,
membership_type=self.membership_type,
member_name=user.get_fullname()
)).insert(ignore_permissions=True)
member_name = member.name
if self.get("__islocal"):
self.member = member_name
if self.get("__islocal"):
self.member = member_name
# get last membership (if active)
last_membership = erpnext.get_last_membership()