From 1b37186460d55199f9d1f4577963e622db418155 Mon Sep 17 00:00:00 2001 From: Zarrar Date: Thu, 6 Sep 2018 13:25:52 +0530 Subject: [PATCH] set POS Invoice format only if its enabled (#15326) --- erpnext/accounts/doctype/sales_invoice/pos.py | 4 ++-- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 +++++- erpnext/selling/page/point_of_sale/point_of_sale.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index a14c2344fe..4ec97c4446 100755 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -12,7 +12,7 @@ from erpnext.setup.utils import get_exchange_rate from erpnext.stock.get_item_details import get_pos_profile from frappe import _ from frappe.core.doctype.communication.email import make -from frappe.utils import nowdate +from frappe.utils import nowdate, cint from six import string_types, iteritems @@ -514,7 +514,7 @@ def make_email_queue(email_queue): name = frappe.db.get_value('Sales Invoice', {'offline_pos_name': key}, 'name') data = json.loads(data) sender = frappe.session.user - print_format = "POS Invoice" + print_format = "POS Invoice" if not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')) else None attachments = [frappe.attach_print('Sales Invoice', name, print_format=print_format)] make(subject=data.get('subject'), content=data.get('content'), recipients=data.get('recipients'), diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 53d0fda1fc..2688b4ff01 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -289,9 +289,13 @@ class SalesInvoice(SellingController): super(SalesInvoice, self).set_missing_values(for_validate) + print_format = pos.get("print_format_for_online") + if not print_format and not cint(frappe.db.get_value('Print Format', 'POS Invoice', 'disabled')): + print_format = 'POS Invoice' + if pos: return { - "print_format": pos.get("print_format_for_online"), + "print_format": print_format, "allow_edit_rate": pos.get("allow_user_to_edit_rate"), "allow_edit_discount": pos.get("allow_user_to_edit_discount") } diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index da72dc570f..a6f7a287be 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -519,7 +519,7 @@ erpnext.pos.PointOfSale = class PointOfSale { this.frm.cscript.calculate_taxes_and_totals(); if (r.message) { - this.frm.meta.default_print_format = r.message.print_format || 'POS Invoice'; + this.frm.meta.default_print_format = r.message.print_format || ""; this.frm.allow_edit_rate = r.message.allow_edit_rate; this.frm.allow_edit_discount = r.message.allow_edit_discount; }