From e2d8dd0663650439e5132192d0368ca9417e5198 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Mon, 22 Jun 2015 19:06:15 +0530 Subject: [PATCH] added recurring print format to sales/purchase invoice and order --- .../doctype/purchase_invoice/purchase_invoice.js | 1 + .../doctype/purchase_invoice/purchase_invoice.json | 11 ++++++++++- .../accounts/doctype/sales_invoice/sales_invoice.js | 2 -- .../doctype/sales_invoice/sales_invoice.json | 11 ++++++++++- .../doctype/purchase_order/purchase_order.json | 11 ++++++++++- erpnext/controllers/recurring_document.py | 2 +- erpnext/public/js/controllers/transaction.js | 12 ++++++++++++ erpnext/selling/doctype/sales_order/sales_order.js | 2 -- erpnext/selling/doctype/sales_order/sales_order.json | 11 ++++++++++- 9 files changed, 54 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 3e16a312cbc..d404851a187 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -224,3 +224,4 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ else cur_frm.pformat.print_heading = __("Purchase Invoice"); } + diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index e192e763180..dcbc60521e8 100755 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -926,12 +926,21 @@ "no_copy": 1, "permlevel": 0, "print_hide": 1 + }, + { + "depends_on": "eval:doc.is_recurring==1", + "fieldname": "recurring_print_format", + "fieldtype": "Link", + "label": "Recurring Print Format", + "options": "Print Format", + "permlevel": 0, + "precision": "" } ], "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-06-16 16:46:47.308287", + "modified": "2015-06-22 07:30:06.743438", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index b35fa8ae84b..3bb9aa0bac3 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -392,8 +392,6 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { } } - - cur_frm.set_query("debit_to", function(doc) { return{ filters: [ diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index a021be41d2f..045678dc545 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -1227,6 +1227,15 @@ "print_hide": 1, "read_only": 0 }, + { + "depends_on": "eval:doc.is_recurring==1", + "fieldname": "recurring_print_format", + "fieldtype": "Link", + "label": "Recurring Print Format", + "options": "Print Format", + "permlevel": 0, + "precision": "" + }, { "fieldname": "against_income_account", "fieldtype": "Small Text", @@ -1244,7 +1253,7 @@ "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-06-16 16:45:06.618286", + "modified": "2015-06-22 06:39:22.072544", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json index dc1dfa42bde..f65ba40a92c 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.json +++ b/erpnext/buying/doctype/purchase_order/purchase_order.json @@ -868,12 +868,21 @@ "no_copy": 1, "permlevel": 0, "print_hide": 1 + }, + { + "depends_on": "eval:doc.is_recurring==1", + "fieldname": "recurring_print_format", + "fieldtype": "Link", + "label": "Recurring Print Format", + "options": "Print Format", + "permlevel": 0, + "precision": "" } ], "icon": "icon-file-text", "idx": 1, "is_submittable": 1, - "modified": "2015-06-15 15:38:56.794601", + "modified": "2015-06-22 07:30:36.259753", "modified_by": "Administrator", "module": "Buying", "name": "Purchase Order", diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py index a46fa324398..8c8af23b58d 100644 --- a/erpnext/controllers/recurring_document.py +++ b/erpnext/controllers/recurring_document.py @@ -124,7 +124,7 @@ def send_notification(new_rv): frappe.sendmail(new_rv.notification_email_address, subject= _("New {0}: #{1}").format(new_rv.doctype, new_rv.name), message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name), - attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name)]) + attachments = [frappe.attach_print(new_rv.doctype, new_rv.name, file_name=new_rv.name, print_format=new_rv.recurring_print_format)]) def notify_errors(doc, doctype, party, owner): from frappe.utils.user import get_system_managers diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index ca0a6cb8d2d..91601a43127 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -37,6 +37,16 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ if(this.frm.fields_dict["items"]) { this["items_remove"] = this.calculate_taxes_and_totals; } + + if(this.frm.fields_dict["recurring_print_format"]) { + this.frm.set_query("recurring_print_format", function(doc) { + return{ + filters: [ + ['Print Format', 'doc_type', '=', cur_frm.doctype], + ] + } + }); + } }, onload_post_render: function() { @@ -782,3 +792,5 @@ frappe.ui.form.on(cur_frm.doctype, "discount_amount", function(frm) { cur_frm.cscript.set_dynamic_labels(); cur_frm.cscript.calculate_taxes_and_totals(); }) + + diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 7ede9d45059..7f0b3861e7c 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -183,5 +183,3 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.email_doc(frappe.boot.notification_settings.sales_order_message); } }; - -; diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index ad62d578d46..59f54fbadcc 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -1074,13 +1074,22 @@ "no_copy": 1, "permlevel": 0, "print_hide": 1 + }, + { + "depends_on": "eval:doc.is_recurring==1", + "fieldname": "recurring_print_format", + "fieldtype": "Link", + "label": "Recurring Print Format", + "options": "Print Format", + "permlevel": 0, + "precision": "" } ], "icon": "icon-file-text", "idx": 1, "is_submittable": 1, "issingle": 0, - "modified": "2015-06-15 15:36:38.898462", + "modified": "2015-06-22 07:29:24.379272", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order",