[fix] edit-profile in frappe;
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index b2351ac..9c532af 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -124,7 +124,8 @@
},
"User": {
"validate": "erpnext.hr.doctype.employee.employee.validate_employee_role",
- "on_update": "erpnext.hr.doctype.employee.employee.update_user_permissions"
+ "on_update": "erpnext.hr.doctype.employee.employee.update_user_permissions",
+ "on_update": "erpnext.utilities.doctype.contact.contact.update_contact"
},
"Sales Taxes and Charges Template": {
"on_update": "erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings.validate_cart_settings"
diff --git a/erpnext/templates/pages/edit-profile.html b/erpnext/templates/pages/edit-profile.html
deleted file mode 100644
index f10e0a3..0000000
--- a/erpnext/templates/pages/edit-profile.html
+++ /dev/null
@@ -1,55 +0,0 @@
-{% extends "templates/web.html" %}
-
-{% block title %} {{ "My Profile" }} {% endblock %}
-
-{% block header %}<h2>My Profile</h2>{% endblock %}
-
-{% block page_content %}
-<div class="user-content" style="max-width: 500px;">
- <div class="alert alert-warning" id="message" style="display: none;"></div>
- <form>
- <fieldset>
- <label>Full Name</label>
- <input class="form-control" type="text" id="fullname" placeholder="Your Name">
- </fieldset>
- <fieldset>
- <label>Company Name</label>
- <input class="form-control" type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}">
- </fieldset>
- <fieldset>
- <label>Mobile No</label>
- <input class="form-control" type="text" id="mobile_no" placeholder="Mobile No" value="{{ mobile_no }}">
- </fieldset>
- <fieldset>
- <label>Phone</label>
- <input class="form-control" type="text" id="phone" placeholder="Phone" value="{{ phone }}">
- </fieldset>
- <button id="update_user" type="submit" class="btn btn-default">Update</button>
- </form>
-</div>
-<script>
-frappe.ready(function() {
- $("#fullname").val(getCookie("full_name") || "");
- $("#update_user").click(function() {
- frappe.call({
- method: "erpnext.templates.pages.edit_profile.update_user",
- type: "POST",
- args: {
- fullname: $("#fullname").val(),
- company_name: $("#company_name").val(),
- mobile_no: $("#mobile_no").val(),
- phone: $("#phone").val()
- },
- btn: this,
- msg: $("#message"),
- callback: function(r) {
- if(!r.exc) $("#user-full-name").html($("#fullname").val());
- }
- });
- return false;
- })
-})
-</script>
-<!-- no-sidebar -->
-{% endblock %}
-
diff --git a/erpnext/templates/pages/edit_profile.py b/erpnext/templates/pages/edit_profile.py
deleted file mode 100644
index 5ab5545..0000000
--- a/erpnext/templates/pages/edit_profile.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# 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
-
-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"])
-
- return {
- "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
- "mobile_no": cstr(mobile_no),
- "phone": cstr(phone)
- }
-
-@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)
-
- if not fullname:
- return _("Name is required")
-
- frappe.db.set_value("User", frappe.session.user, "first_name", fullname)
- frappe.local.cookie_manager.set_cookie("full_name", fullname)
-
- return _("Updated")
diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py
index dff05bc..ae2fdfb 100644
--- a/erpnext/utilities/doctype/contact/contact.py
+++ b/erpnext/utilities/doctype/contact/contact.py
@@ -92,3 +92,13 @@
"contact_department": contact.get("department")
}
return out
+
+def update_contact(doc, method):
+ '''Update contact when user is updated, if contact is found. Called via hooks'''
+ contact_name = frappe.db.get_value("Contact", {"email_id": doc.name})
+ if contact_name:
+ contact = frappe.get_doc("Contact", contact_name)
+ contact.first_name = doc.first_name
+ contact.last_name = doc.last_name
+ contact.phone = doc.phone
+ contact.save(ignore_permissions=True)