From b87e9f2651c423c167fdf2e81c3bec6f98b3137f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Jan 2014 19:51:36 +0530 Subject: [PATCH] Fixes in fetching party details --- .../sales_invoice/test_sales_invoice.py | 8 ++-- erpnext/public/js/utils/party.js | 37 +++++++++++-------- erpnext/selling/doctype/customer/customer.py | 7 ++-- erpnext/utilities/doctype/contact/contact.py | 3 +- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 3092477e4f..2ed9847c07 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -756,16 +756,18 @@ class TestSalesInvoice(unittest.TestCase): def _test_recurring_invoice(self, base_si, first_and_last_day): from webnotes.utils import add_months, get_last_day - from erpnext.accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices + from erpnext.accounts.doctype.sales_invoice.sales_invoice \ + import manage_recurring_invoices, get_next_date no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.doc.recurring_type] def _test(i): self.assertEquals(i+1, webnotes.conn.sql("""select count(*) from `tabSales Invoice` where recurring_id=%s and docstatus=1""", base_si.doc.recurring_id)[0][0]) - - next_date = add_months(base_si.doc.posting_date, no_of_months) + next_date = get_next_date(base_si.doc.posting_date, no_of_months, + base_si.doc.repeat_on_day_of_month) + manage_recurring_invoices(next_date=next_date, commit=False) recurred_invoices = webnotes.conn.sql("""select name from `tabSales Invoice` diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js index c068ff2417..bda44cea7e 100644 --- a/erpnext/public/js/utils/party.js +++ b/erpnext/public/js/utils/party.js @@ -48,24 +48,29 @@ erpnext.utils.get_address_display = function(frm, address_field) { address_field = "supplier_address"; } } - wn.call({ - method: "erpnext.utilities.doctype.address.address.get_address_display", - args: {address: frm.doc[address_field] }, - callback: function(r) { - if(r.message) - frm.set_value("address_display", r.message) - } - }) + if(frm.doc[address_field]) { + wn.call({ + method: "erpnext.utilities.doctype.address.address.get_address_display", + args: {address: frm.doc[address_field] }, + callback: function(r) { + if(r.message) + frm.set_value("address_display", r.message) + } + }) + } } erpnext.utils.get_contact_details = function(frm) { if(frm.updating_party_details) return; - wn.call({ - method: "erpnext.utilities.doctype.contact.contact.get_contact_details", - args: {address: frm.doc.contact_person }, - callback: function(r) { - if(r.message) - frm.set_value(r.message); - } - }) + + if(frm.doc[address_field]) { + wn.call({ + method: "erpnext.utilities.doctype.contact.contact.get_contact_details", + args: {contact: frm.doc.contact_person }, + callback: function(r) { + if(r.message) + frm.set_value(r.message); + } + }) + } } \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index aa28a19d3d..c182c947a1 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -196,13 +196,14 @@ def get_customer_details(customer, price_list=None, currency=None): out[f] = customer.get("default_" + f) # price list - out.selling_price_list = webnotes.conn.get_defaults("selling_price_list", webnotes.session.user) + from webnotes.defaults import get_defaults_for + out.selling_price_list = get_defaults_for(webnotes.session.user).get(price_list) if isinstance(out.selling_price_list, list): out.selling_price_list = None out.selling_price_list = out.selling_price_list or customer.price_list \ - or webnotes.conn.get_value("Customer Group", customer.customer_group, "default_price_list") - or price_list + or webnotes.conn.get_value("Customer Group", + customer.customer_group, "default_price_list") or price_list if out.selling_price_list: out.price_list_currency = webnotes.conn.get_value("Price List", out.selling_price_list, "currency") diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py index 9dcb30de33..2abd0dc550 100644 --- a/erpnext/utilities/doctype/contact/contact.py +++ b/erpnext/utilities/doctype/contact/contact.py @@ -64,5 +64,4 @@ def get_contact_details(contact): "contact_department": contact.get("department") } - return out - \ No newline at end of file + return out \ No newline at end of file