brotherton-erpnext/erpnext/templates/pages/edit_profile.py

36 lines
1.1 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2014-10-21 10:46:30 +00:00
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cstr
from erpnext.shopping_cart.cart import get_customer
2014-10-21 10:46:30 +00:00
no_cache = 1
no_sitemap = 1
def get_context(context):
party = get_customer()
mobile_no, phone = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
"customer": party.name}, ["mobile_no", "phone"])
2014-10-21 10:46:30 +00:00
return {
"company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
"mobile_no": cstr(mobile_no),
"phone": cstr(phone)
}
2014-10-21 10:46:30 +00:00
@frappe.whitelist()
def update_user(fullname, password=None, company_name=None, mobile_no=None, phone=None):
from erpnext.shopping_cart.cart import update_party
update_party(fullname, company_name, mobile_no, phone)
2014-10-21 10:46:30 +00:00
if not fullname:
return _("Name is required")
2014-10-21 10:46:30 +00:00
frappe.db.set_value("User", frappe.session.user, "first_name", fullname)
frappe.local.cookie_manager.set_cookie("full_name", fullname)
2014-10-21 10:46:30 +00:00
return _("Updated")