[Mod] Refactored the code for fetching allow_print_before_pay check value
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index ab40e8c..91997d9 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -303,6 +303,36 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "allow_print_before_pay",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Allow Print Before Pay ",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "offline_pos_name",
"fieldtype": "Data",
"hidden": 1,
@@ -4563,7 +4593,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2018-01-11 14:02:48.829906",
+ "modified": "2018-01-09 09:48:00.152026",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index f6d43c7..6562075 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -304,6 +304,8 @@
self.account_for_change_amount = frappe.db.get_value('Company', self.company, 'default_cash_account')
if pos:
+ self.allow_print_before_pay = pos.allow_print_before_pay
+
if not for_validate and not self.customer:
self.customer = pos.customer
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 4c532a5..b16d20d 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -51,10 +51,10 @@
},
() => this.setup_company(),
() => this.make_new_invoice(),
+ () => this.set_form_action(),
() => {
frappe.dom.unfreeze();
},
- () => this.fetch_pos_profile_data(),
() => this.page.set_title(__('Point of Sale'))
]);
}
@@ -475,23 +475,6 @@
});
}
- fetch_pos_profile_data() {
- var me = this;
- me.frm.doc["allow_print_before_pay"] = 0;
- return new Promise(resolve => {
- return this.frm.call({
- method:"erpnext.selling.page.point_of_sale.point_of_sale.fetch_pos_profile_detail",
- args:{
- pos_profile:me.frm.doc.pos_profile
- }
- }).then((r) => {
- me.frm.doc["allow_print_before_pay"] = r.message;
- this.set_form_action();
- resolve();
- });
- });
- }
-
prepare_menu() {
var me = this;
this.page.clear_menu();
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index c54f28a..9389188 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -127,10 +127,4 @@
return frappe.db.sql(""" select distinct name from `tabItem Group`
where {condition} and (name like %(txt)s) limit {start}, {page_len}"""
.format(condition = cond, start=start, page_len= page_len),
- {'txt': '%%%s%%' % txt})
-
-@frappe.whitelist()
-def fetch_pos_profile_detail(pos_profile):
- pos_profile_doc = frappe.get_doc("POS Profile",pos_profile)
- allow_print_before_pay_check = pos_profile_doc.allow_print_before_pay
- return allow_print_before_pay_check
\ No newline at end of file
+ {'txt': '%%%s%%' % txt})
\ No newline at end of file