refactor(member): drop email column

* remove email column
* update controller methods
* add patch to add value from email to email_id
This commit is contained in:
Shivam Mishra 2020-11-09 12:29:03 +05:30
parent d75ff1a93e
commit 9d9fa74e6b
4 changed files with 28 additions and 12 deletions

View File

@ -12,7 +12,6 @@
"membership_expiry_date",
"column_break_5",
"membership_type",
"email",
"email_id",
"image",
"customer_section",
@ -64,13 +63,6 @@
"options": "Membership Type",
"reqd": 1
},
{
"fieldname": "email",
"fieldtype": "Link",
"in_list_view": 1,
"label": "User",
"options": "User"
},
{
"fieldname": "image",
"fieldtype": "Attach Image",
@ -178,7 +170,7 @@
],
"image_field": "image",
"links": [],
"modified": "2020-09-16 23:44:13.596948",
"modified": "2020-11-09 12:12:10.174647",
"modified_by": "Administrator",
"module": "Non Profit",
"name": "Member",

View File

@ -24,7 +24,7 @@ class Membership(Document):
user = frappe.get_doc('User', frappe.session.user)
member = frappe.get_doc(dict(
doctype='Member',
email=frappe.session.user,
email_id=frappe.session.user,
membership_type=self.membership_type,
member_name=user.get_fullname()
)).insert(ignore_permissions=True)
@ -97,8 +97,12 @@ class Membership(Document):
frappe.throw(_("You need to enable <b>Send Acknowledge Email</b> in Membership Settings"))
member = frappe.get_doc("Member", self.member)
if not member.email_id:
frappe.throw(_("Email address of member {0} is missing").format(frappe.utils.get_link_to_form("Member", self.member)))
plan = frappe.get_doc("Membership Type", self.membership_type)
email = member.email_id if member.email_id else member.email
email = member.email_id
attachments = [frappe.attach_print("Membership", self.name, print_format=settings.membership_print_format)]
if self.invoice and settings.send_invoice:

View File

@ -733,4 +733,5 @@ erpnext.patches.v13_0.print_uom_after_quantity_patch
erpnext.patches.v13_0.set_payment_channel_in_payment_gateway_account
erpnext.patches.v13_0.create_healthcare_custom_fields_in_stock_entry_detail
erpnext.patches.v13_0.update_reason_for_resignation_in_employee
execute:frappe.delete_doc("Report", "Quoted Item Comparison")
execute:frappe.delete_doc("Report", "Quoted Item Comparison")
erpnext.patches.v13_0.update_member_email_address

View File

@ -0,0 +1,19 @@
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
"""add value to email_id column from email"""
if frappe.db.has_column("Member", "email"):
# Get all members
for member in frappe.db.get_all("Member", pluck="name"):
# Check if email_id already exists
if not frappe.db.get_value("Member", member, "email_id"):
# fetch email id from the user linked field email
email = frappe.db.get_value("Member", member, "email")
# Set the value for it
frappe.db.set_value("Member", member, "email_id", email)