From 3987b4b714b1749542726748bf6c6b4dcf999205 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Wed, 3 Apr 2019 08:53:03 +0530 Subject: [PATCH] fix: Test case fixes in quotation for dynamic column --- erpnext/crm/doctype/opportunity/opportunity.py | 4 ++-- erpnext/selling/doctype/customer/customer.py | 5 ++--- erpnext/selling/doctype/quotation/quotation.py | 2 +- erpnext/selling/doctype/quotation/test_quotation.py | 10 +++++----- erpnext/shopping_cart/test_shopping_cart.py | 9 ++++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index e8da4e6436b..102d7378287 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -218,8 +218,8 @@ def make_quotation(source_name, target_doc=None): quotation = frappe.get_doc(target) company_currency = frappe.get_cached_value('Company', quotation.company, "default_currency") - party_account_currency = get_party_account_currency("Customer", quotation.customer, - quotation.company) if quotation.customer else company_currency + party_account_currency = get_party_account_currency("Customer", quotation.customer_lead, + quotation.company) if quotation.customer_lead else company_currency quotation.currency = party_account_currency or company_currency diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 2970d7a5e82..139d76157e7 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -104,9 +104,8 @@ class Customer(TransactionBase): if self.lead_name: frappe.db.set_value('Lead', self.lead_name, 'status', 'Converted', update_modified=False) - for doctype in ('Opportunity', 'Quotation'): - for d in frappe.get_all(doctype, {'lead': self.lead_name}): - frappe.db.set_value(doctype, d.name, 'customer', self.name, update_modified=False) + for d in frappe.get_all('Opportunity', {'lead': self.lead_name}): + frappe.db.set_value('Opportunity', d.name, 'customer', self.name, update_modified=False) def create_lead_address_contact(self): if self.lead_name: diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index c1529bb322b..524a7a6039b 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -204,7 +204,7 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): return doclist def _make_customer(source_name, ignore_permissions=False): - quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type", "customer"]) + quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "customer_lead"]) if quotation and quotation[0] and not quotation[2]: lead_name = quotation[0] customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name}, diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 78fb0c14042..124c7922a80 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -203,15 +203,15 @@ class TestQuotation(unittest.TestCase): test_records = frappe.get_test_records('Quotation') -def get_quotation_dict(customer=None, item_code=None): - if not customer: - customer = '_Test Customer' +def get_quotation_dict(customer_lead=None, item_code=None): + if not customer_lead: + customer_lead = '_Test Customer' if not item_code: item_code = '_Test Item' return { 'doctype': 'Quotation', - 'customer': customer, + 'customer_lead': customer_lead, 'items': [ { 'item_code': item_code, @@ -229,7 +229,7 @@ def make_quotation(**args): qo.transaction_date = args.transaction_date qo.company = args.company or "_Test Company" - qo.customer = args.customer or "_Test Customer" + qo.customer_lead = args.customer_lead or "_Test Customer" qo.currency = args.currency or "INR" if args.selling_price_list: qo.selling_price_list = args.selling_price_list diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py index 7d6b41ef5fc..d1124a662b6 100644 --- a/erpnext/shopping_cart/test_shopping_cart.py +++ b/erpnext/shopping_cart/test_shopping_cart.py @@ -33,7 +33,7 @@ class TestShoppingCart(unittest.TestCase): self.assertEqual(quotation.quotation_to, "Customer") self.assertEqual(quotation.contact_person, frappe.db.get_value("Contact", dict(email_id="test_cart_user@example.com"))) - self.assertEqual(quotation.lead, None) + self.assertEqual(quotation.customer_lead, None) self.assertEqual(quotation.contact_email, frappe.session.user) return quotation @@ -44,8 +44,7 @@ class TestShoppingCart(unittest.TestCase): # test if quotation with customer is fetched quotation = _get_cart_quotation() self.assertEqual(quotation.quotation_to, "Customer") - self.assertEqual(quotation.customer, "_Test Customer") - self.assertEqual(quotation.lead, None) + self.assertEqual(quotation.customer_lead, "_Test Customer") self.assertEqual(quotation.contact_email, frappe.session.user) return quotation @@ -107,7 +106,7 @@ class TestShoppingCart(unittest.TestCase): from erpnext.accounts.party import set_taxes - tax_rule_master = set_taxes(quotation.customer, "Customer", \ + tax_rule_master = set_taxes(quotation.customer_lead, "Customer", \ quotation.transaction_date, quotation.company, None, None, \ quotation.customer_address, quotation.shipping_address_name, 1) self.assertEqual(quotation.taxes_and_charges, tax_rule_master) @@ -122,7 +121,7 @@ class TestShoppingCart(unittest.TestCase): "doctype": "Quotation", "quotation_to": "Customer", "order_type": "Shopping Cart", - "customer": get_party(frappe.session.user).name, + "customer_lead": get_party(frappe.session.user).name, "docstatus": 0, "contact_email": frappe.session.user, "selling_price_list": "_Test Price List Rest of the World",