From f90df7da02bdb2ae43e00a92c0064a76398354e8 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 29 Jul 2013 19:53:44 +0530 Subject: [PATCH] [fix] [minor] if customer_account is mentioned in POS Settings, also fetch customer_name --- accounts/doctype/sales_invoice/sales_invoice.py | 8 +++++++- selling/utils.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index c27f999fcf..ca93786054 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -174,8 +174,8 @@ class DocType(SellingController): self.convert_to_recurring() def set_missing_values(self, for_validate=False): - super(DocType, self).set_missing_values(for_validate) self.set_pos_fields(for_validate) + super(DocType, self).set_missing_values(for_validate) def set_customer_defaults(self): # TODO cleanup these methods @@ -216,6 +216,12 @@ class DocType(SellingController): "docstatus": ["!=", 2] }) or pos.customer_account + if self.doc.debit_to and not self.doc.customer: + self.doc.customer = webnotes.conn.get_value("Account", { + "name": self.doc.debit_to, + "master_type": "Customer" + }, "master_name") + for fieldname in ('territory', 'naming_series', 'currency', 'charge', 'letter_head', 'tc_name', 'price_list_name', 'company', 'select_print_heading', 'cash_bank_account'): if (not for_validate) or (for_validate and not self.doc.fields.get(fieldname)): diff --git a/selling/utils.py b/selling/utils.py index bf4f0811ec..d24a35072f 100644 --- a/selling/utils.py +++ b/selling/utils.py @@ -190,7 +190,7 @@ def get_pos_settings(company): if not pos_settings: pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting` where ifnull(user,'') = '' and company = %s""", company, as_dict=1) - + return pos_settings and pos_settings[0] or None def apply_pos_settings(pos_settings, opts):