[minor] fixes for Contact
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index d3db4c9..e52ef81 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -182,8 +182,7 @@
(party.doctype.lower()): party.name
})
- qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
- "customer": party.name})
+ qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
qdoc.contact_email = frappe.session.user
qdoc.flags.ignore_permissions = True
@@ -198,8 +197,7 @@
party.customer_name = company_name or fullname
party.customer_type == "Company" if company_name else "Individual"
- contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
- "customer": party.name})
+ contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
contact = frappe.get_doc("Contact", contact_name)
contact.first_name = fullname
contact.last_name = None
@@ -291,10 +289,14 @@
if not user:
user = frappe.session.user
- party = frappe.db.get_value("Contact", {"email_id": user}, ["customer", "supplier"], as_dict=1)
- if party:
- party_doctype = 'Customer' if party.customer else 'Supplier'
- party = party.customer or party.supplier
+ contact_name = frappe.db.get_value("Contact", {"email_id": user})
+ party = None
+
+ if contact_name:
+ contact = frappe.get_doc('Contact', contact_name)
+ if contact.links:
+ party_doctype = contact.links[0].link_doctype
+ party = contact.links[0].link_name
cart_settings = frappe.get_doc("Shopping Cart Settings")
@@ -331,10 +333,10 @@
contact = frappe.new_doc("Contact")
contact.update({
- "customer": customer.name,
"first_name": fullname,
"email_id": user
})
+ contact.append('links', dict(link_doctype='Customer', link_name=customer.name))
contact.flags.ignore_mandatory = True
contact.insert(ignore_permissions=True)
diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py
index 5282231..698d467 100644
--- a/erpnext/shopping_cart/test_shopping_cart.py
+++ b/erpnext/shopping_cart/test_shopping_cart.py
@@ -25,8 +25,8 @@
# test if lead is created and quotation with new lead is fetched
quotation = _get_cart_quotation()
self.assertEquals(quotation.quotation_to, "Customer")
- self.assertEquals(frappe.db.get_value("Contact", {"customer": quotation.customer}, "email_id"),
- "test_cart_user@example.com")
+ self.assertEquals(frappe.db.get_value("Contact", dict(contact_person="test_cart_user@example.com")),
+ quotation.contact_name)
self.assertEquals(quotation.lead, None)
self.assertEquals(quotation.contact_email, frappe.session.user)
@@ -101,7 +101,7 @@
quotation = self.create_quotation()
from erpnext.accounts.party import set_taxes
-
+
tax_rule_master = set_taxes(quotation.customer, "Customer", \
quotation.transaction_date, quotation.company, None, None, \
quotation.customer_address, quotation.shipping_address_name, 1)
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index 36d0876..f2d8bd5 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -33,11 +33,11 @@
if not self.lead:
self.lead = frappe.db.get_value("Lead", {"email_id": email_id})
if not self.contact:
- values = frappe.db.get_value("Contact",
- {"email_id": email_id}, ("name", "customer"))
+ self.contact = frappe.db.get_value("Contact", {"email_id": email_id})
- if values:
- self.contact, self.customer = values
+ if self.contact:
+ contact = frappe.get_doc('Contact', self.contact)
+ self.customer = contact.get_link_for('Customer')
if not self.company:
self.company = frappe.db.get_value("Lead", self.lead, "company") or \