[fix] [minor] if customer_account is mentioned in POS Settings, also fetch customer_name
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index c27f999..ca93786 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -174,8 +174,8 @@
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 @@
"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 bf4f081..d24a350 100644
--- a/selling/utils.py
+++ b/selling/utils.py
@@ -190,7 +190,7 @@
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):