From cb98d9ec5ff61faf887237b324ad6321ef56f4b5 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 17 Dec 2015 09:48:44 +0530 Subject: [PATCH] [fixes] print format listing --- .../payment_request/payment_request.js | 9 +++++++++ .../payment_request/payment_request.json | 4 ++-- .../payment_request/payment_request.py | 20 ++++++++++++++++--- erpnext/selling/sales_common.js | 4 +++- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 erpnext/accounts/doctype/payment_request/payment_request.js diff --git a/erpnext/accounts/doctype/payment_request/payment_request.js b/erpnext/accounts/doctype/payment_request/payment_request.js new file mode 100644 index 00000000000..142eacf95a0 --- /dev/null +++ b/erpnext/accounts/doctype/payment_request/payment_request.js @@ -0,0 +1,9 @@ +frappe.ui.form.on("Payment Request", "onload", function(frm, dt, dn){ + frappe.call({ + method:"erpnext.accounts.doctype.payment_request.payment_request.get_print_format_list", + args: {"ref_doctype": frm.doc.reference_doctype}, + callback:function(r){ + set_field_options("print_format", r.message["print_format"]) + } + }) +}) \ No newline at end of file diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json index add555e3141..25f786a70ae 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.json +++ b/erpnext/accounts/doctype/payment_request/payment_request.json @@ -218,7 +218,7 @@ "label": "Print Format", "length": 0, "no_copy": 0, - "options": "Standard\nPOS Invoice", + "options": "", "permlevel": 0, "precision": "", "print_hide": 0, @@ -410,7 +410,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2015-12-16 17:31:37.319394", + "modified": "2015-12-17 09:41:59.801913", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Request", diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index e8c824a7188..d1bfc9fc184 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -7,10 +7,10 @@ import frappe from frappe.model.document import Document from frappe.utils import flt, today from frappe import _ -from erpnext.accounts.doctype.journal_entry.journal_entry import (get_payment_entry_against_order, -get_payment_entry_against_invoice, get_payment_entry) +from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry from erpnext.accounts.party import get_party_account from erpnext.accounts.utils import get_account_currency, get_balance_on +from itertools import chain class PaymentRequest(Document): def validate(self): @@ -135,6 +135,8 @@ def make_payment_request(dt, dn, recipient_id=None): "reference_doctype": dt, "reference_name": dn }).insert() + + return pr.name def get_reference_doc_details(dt, dn): """ return reference doc Sales Order/Sales Invoice""" @@ -155,4 +157,16 @@ def get_amount(ref_doc, dt): def get_gateway_details(): """return gateway and payment account of default payment gateway""" - return frappe.db.get_value("Payment Gateway", {"is_default": 1}, ["gateway", "payment_account"]) \ No newline at end of file + return frappe.db.get_value("Payment Gateway", {"is_default": 1}, ["gateway", "payment_account"]) + +@frappe.whitelist() +def get_print_format_list(ref_doctype): + print_format_list = ["Standard"] + + print_format_list.extend(list(chain.from_iterable(frappe.db.sql("""select name from `tabPrint Format` + where doc_type=%s""", ref_doctype, as_list=1)))) + + return { + "print_format": print_format_list + } + \ No newline at end of file diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 044638223f9..66422f09df5 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -299,7 +299,9 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ "recipient_id": cur_frm.doc.contact_email }, callback: function(r) { - + if(!r.exc){ + frappe.msgprint(__("payment Request generated")) + } } }) }