[minor] fixes for Contact
This commit is contained in:
parent
820abd3ba4
commit
4ad121e1a4
@ -182,8 +182,7 @@ def _get_cart_quotation(party=None):
|
|||||||
(party.doctype.lower()): party.name
|
(party.doctype.lower()): party.name
|
||||||
})
|
})
|
||||||
|
|
||||||
qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
|
qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
|
||||||
"customer": party.name})
|
|
||||||
qdoc.contact_email = frappe.session.user
|
qdoc.contact_email = frappe.session.user
|
||||||
|
|
||||||
qdoc.flags.ignore_permissions = True
|
qdoc.flags.ignore_permissions = True
|
||||||
@ -198,8 +197,7 @@ def update_party(fullname, company_name=None, mobile_no=None, phone=None):
|
|||||||
party.customer_name = company_name or fullname
|
party.customer_name = company_name or fullname
|
||||||
party.customer_type == "Company" if company_name else "Individual"
|
party.customer_type == "Company" if company_name else "Individual"
|
||||||
|
|
||||||
contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
|
contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
|
||||||
"customer": party.name})
|
|
||||||
contact = frappe.get_doc("Contact", contact_name)
|
contact = frappe.get_doc("Contact", contact_name)
|
||||||
contact.first_name = fullname
|
contact.first_name = fullname
|
||||||
contact.last_name = None
|
contact.last_name = None
|
||||||
@ -291,10 +289,14 @@ def get_party(user=None):
|
|||||||
if not user:
|
if not user:
|
||||||
user = frappe.session.user
|
user = frappe.session.user
|
||||||
|
|
||||||
party = frappe.db.get_value("Contact", {"email_id": user}, ["customer", "supplier"], as_dict=1)
|
contact_name = frappe.db.get_value("Contact", {"email_id": user})
|
||||||
if party:
|
party = None
|
||||||
party_doctype = 'Customer' if party.customer else 'Supplier'
|
|
||||||
party = party.customer or party.supplier
|
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")
|
cart_settings = frappe.get_doc("Shopping Cart Settings")
|
||||||
|
|
||||||
@ -331,10 +333,10 @@ def get_party(user=None):
|
|||||||
|
|
||||||
contact = frappe.new_doc("Contact")
|
contact = frappe.new_doc("Contact")
|
||||||
contact.update({
|
contact.update({
|
||||||
"customer": customer.name,
|
|
||||||
"first_name": fullname,
|
"first_name": fullname,
|
||||||
"email_id": user
|
"email_id": user
|
||||||
})
|
})
|
||||||
|
contact.append('links', dict(link_doctype='Customer', link_name=customer.name))
|
||||||
contact.flags.ignore_mandatory = True
|
contact.flags.ignore_mandatory = True
|
||||||
contact.insert(ignore_permissions=True)
|
contact.insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
|||||||
@ -25,8 +25,8 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
# test if lead is created and quotation with new lead is fetched
|
# test if lead is created and quotation with new lead is fetched
|
||||||
quotation = _get_cart_quotation()
|
quotation = _get_cart_quotation()
|
||||||
self.assertEquals(quotation.quotation_to, "Customer")
|
self.assertEquals(quotation.quotation_to, "Customer")
|
||||||
self.assertEquals(frappe.db.get_value("Contact", {"customer": quotation.customer}, "email_id"),
|
self.assertEquals(frappe.db.get_value("Contact", dict(contact_person="test_cart_user@example.com")),
|
||||||
"test_cart_user@example.com")
|
quotation.contact_name)
|
||||||
self.assertEquals(quotation.lead, None)
|
self.assertEquals(quotation.lead, None)
|
||||||
self.assertEquals(quotation.contact_email, frappe.session.user)
|
self.assertEquals(quotation.contact_email, frappe.session.user)
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class TestShoppingCart(unittest.TestCase):
|
|||||||
quotation = self.create_quotation()
|
quotation = self.create_quotation()
|
||||||
|
|
||||||
from erpnext.accounts.party import set_taxes
|
from erpnext.accounts.party import set_taxes
|
||||||
|
|
||||||
tax_rule_master = set_taxes(quotation.customer, "Customer", \
|
tax_rule_master = set_taxes(quotation.customer, "Customer", \
|
||||||
quotation.transaction_date, quotation.company, None, None, \
|
quotation.transaction_date, quotation.company, None, None, \
|
||||||
quotation.customer_address, quotation.shipping_address_name, 1)
|
quotation.customer_address, quotation.shipping_address_name, 1)
|
||||||
|
|||||||
@ -33,11 +33,11 @@ class Issue(Document):
|
|||||||
if not self.lead:
|
if not self.lead:
|
||||||
self.lead = frappe.db.get_value("Lead", {"email_id": email_id})
|
self.lead = frappe.db.get_value("Lead", {"email_id": email_id})
|
||||||
if not self.contact:
|
if not self.contact:
|
||||||
values = frappe.db.get_value("Contact",
|
self.contact = frappe.db.get_value("Contact", {"email_id": email_id})
|
||||||
{"email_id": email_id}, ("name", "customer"))
|
|
||||||
|
|
||||||
if values:
|
if self.contact:
|
||||||
self.contact, self.customer = values
|
contact = frappe.get_doc('Contact', self.contact)
|
||||||
|
self.customer = contact.get_link_for('Customer')
|
||||||
|
|
||||||
if not self.company:
|
if not self.company:
|
||||||
self.company = frappe.db.get_value("Lead", self.lead, "company") or \
|
self.company = frappe.db.get_value("Lead", self.lead, "company") or \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user