set POS Invoice format only if its enabled (#15326)

This commit is contained in:
Zarrar 2018-09-06 13:25:52 +05:30 committed by Nabin Hait
parent 2705af488d
commit 1b37186460
3 changed files with 8 additions and 4 deletions

View File

@ -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'),

View File

@ -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")
}

View File

@ -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;
}