[enhance] connect new buttons on dashboard to custom make buttons and fix text for payment request

This commit is contained in:
Rushabh Mehta 2017-02-23 17:03:46 +05:30
parent 8c9bc8edbb
commit 509543752c
16 changed files with 140 additions and 40 deletions

View File

@ -362,7 +362,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "message",
"fieldtype": "Small Text",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@ -400,7 +400,7 @@
"label": "Message Examples",
"length": 0,
"no_copy": 0,
"options": "<pre><h5>Message Example</h5>\n\n&lt;p&gt; Thank You for being a part of {{ doc.company }}! We hope you are enjoying the service.&lt;/p&gt;\n\n&lt;p&gt; Please find enclosed the E Bill statement. The outstanding amount is {{ doc.grand_total }}.&lt;/p&gt;\n\n&lt;p&gt; We don't want you to be spending time running around in order to pay for your Bill.<br>After all, life is beautiful and the time you have in hand should be spent to enjoy it!<br>So here are our little ways to help you get more time for life! &lt;/p&gt;\n\n&lt;a href=\"{{ payment_url }}\"&gt; click here to pay &lt;/a&gt;\n\n</pre>\n",
"options": "<pre><h5>Message Example</h5>\n\n&lt;p&gt;Dear {{ doc.contact_person }},&lt;/p&gt;\n\n&lt;p&gt;Requesting payment for {{ doc.doctype }}, {{ doc.name }} for {{ doc.grand_total }}.&lt;/p&gt;\n\n&lt;a href=\"{{ payment_url }}\"&gt; click here to pay &lt;/a&gt;\n\n</pre>\n",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@ -675,13 +675,13 @@
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 1,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-12-15 14:46:19.662816",
"modified": "2017-02-23 05:03:37.464863",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Request",

View File

@ -234,7 +234,7 @@ def make_payment_request(**args):
"grand_total": grand_total,
"email_to": args.recipient_id or "",
"subject": "Payment Request for %s"%args.dn,
"message": gateway_account.get("message") or get_dummy_message(args.use_dummy_message),
"message": gateway_account.get("message") or get_dummy_message(ref_doc),
"reference_doctype": args.dt,
"reference_name": args.dn
})
@ -326,12 +326,17 @@ def make_status_as_paid(doc, method):
doc.db_set('status', 'Paid')
frappe.db.commit()
def get_dummy_message(use_dummy_message=True):
return """
<p> Hope you are enjoying a service. Please consider bank details for payment </p>
<p> Bank Details <p><br>
<p> Bank Name : National Bank </p>
<p> Account Number : 123456789000872 </p>
<p> IFSC code : NB000001 </p>
<p> Account Name : Wind Power LLC </p>
"""
def get_dummy_message(doc):
return frappe.render_template("""{% if doc.contact_person -%}
<p>Dear {{ doc.contact_person }},</p>
{%- else %}<p>Hello,</p>{% endif %}
<p>{{ _("Requesting payment against {0} {1} for amount {2}").format(doc.doctype,
doc.name, doc.get_formatted("grand_total")) }}</p>
<a href="{{ payment_url }}">{{ _("Make Payment") }}</a>
<p>{{ _("If you have any questions, please get back to us.") }}</p>
<p>{{ _("Thank you for your business!") }}</p>
""", dict(doc=doc, payment_url = '{{ payment_url }}'))

View File

@ -336,6 +336,12 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
}
frappe.ui.form.on("Purchase Invoice", {
setup: function(frm) {
frm.custom_make_buttons = {
'Purchase Invoice': 'Debit Note',
'Payment Entry': 'Payment'
}
},
onload: function(frm) {
$.each(["warehouse", "rejected_warehouse"], function(i, field) {
frm.set_query(field, "items", function() {

View File

@ -469,6 +469,12 @@ cur_frm.set_query("asset", "items", function(doc, cdt, cdn) {
frappe.ui.form.on('Sales Invoice', {
setup: function(frm){
frm.custom_make_buttons = {
'Delivery Note': 'Delivery',
'Sales Invoice': 'Sales Return',
'Payment Request': 'Payment Request',
'Payment': 'Payment Entry'
},
frm.fields_dict["timesheets"].grid.get_field("time_sheet").get_query = function(doc, cdt, cdn){
return{
query: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet",

View File

@ -6,6 +6,13 @@ frappe.provide("erpnext.buying");
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
frappe.ui.form.on("Purchase Order", {
setup: function(frm) {
frm.custom_make_buttons = {
'Purchase Receipt': 'Receive',
'Purchase Invoice': 'Invoice',
'Stock Entry': 'Material to Supplier'
}
},
onload: function(frm) {
erpnext.queries.setup_queries(frm, "Warehouse", function() {
return erpnext.queries.warehouse(frm.doc);
@ -28,10 +35,8 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
var item = cur_frm.doc.items[i];
if(item.delivered_by_supplier !== 1) {
allow_receipt = true;
}
else {
is_drop_ship = true
} else {
is_drop_ship = true;
}
if(is_drop_ship && allow_receipt) {

View File

@ -8,6 +8,10 @@ cur_frm.add_fetch('contact', 'email_id', 'email_id')
frappe.ui.form.on("Request for Quotation",{
setup: function(frm) {
frm.custom_make_buttons = {
'Supplier Quotation': 'Supplier Quotation'
}
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function(doc, cdt, cdn){
var d =locals[cdt][cdn];
return {

View File

@ -4,6 +4,14 @@
// attach required files
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
frappe.ui.form.on('Suppier Quotation', {
setup: function() {
frm.custom_make_buttons = {
'Purchase Order': 'Purchase Order'
}
}
});
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
refresh: function() {
this._super();

View File

@ -5,6 +5,12 @@ frappe.provide("erpnext.crm");
cur_frm.email_field = "contact_email";
frappe.ui.form.on("Opportunity", {
setup: function(frm) {
frm.custom_make_buttons = {
'Quotation': 'Quotation',
'Supplier Quotation': 'Supplier Quotation'
}
},
customer: function(frm) {
erpnext.utils.get_party_details(frm);
},

View File

@ -8,7 +8,6 @@ def get_data():
},
'transactions': [
{
'label': _('Related'),
'items': ['Quotation', 'Supplier Quotation']
},
]

View File

@ -46,11 +46,26 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) {
frm.updating_party_details = false;
if(callback) callback();
frm.refresh();
erpnext.utils.add_item(frm);
}
}
});
}
erpnext.utils.add_item = function(frm) {
if(frm.is_new()) {
var prev_route = frappe.get_prev_route();
if(prev_route[1]==='Item' && !(frm.doc.items && frm.doc.items.length)) {
// add row
item = frm.add_child('items');
frm.refresh_field('items');
// set item
frappe.model.set_value(item.doctype, item.name, 'item_code', prev_route[2]);
}
}
}
erpnext.utils.get_address_display = function(frm, address_field, display_field, is_your_company_address) {
if(frm.updating_party_details) return;

View File

@ -4,6 +4,14 @@
{% include 'erpnext/selling/sales_common.js' %}
frappe.ui.form.on('Quotation', {
setup: function(frm) {
frm.custom_make_buttons = {
'Sales Order': 'Make Sales Order'
}
}
});
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
onload: function(doc, dt, dn) {
var me = this;

View File

@ -4,6 +4,14 @@
{% include 'erpnext/selling/sales_common.js' %}
frappe.ui.form.on("Sales Order", {
setup: function(frm) {
frm.custom_make_buttons = {
'Delivery Note': 'Delivery',
'Sales Invoice': 'Invoice',
'Material Request': 'Material Request',
'Purchase Order': 'Purchase Order'
}
},
onload: function(frm) {
erpnext.queries.setup_queries(frm, "Warehouse", function() {
return erpnext.queries.warehouse(frm.doc);

View File

@ -8,6 +8,12 @@ frappe.provide("erpnext.stock.delivery_note");
frappe.ui.form.on("Delivery Note", {
setup: function(frm) {
frm.custom_make_buttons = {
'Packing Slip': 'Packing Slip',
'Installation Note': 'Installation Note',
'Sales Invoice': 'Invoice',
'Stock Entry': 'Return',
},
frm.set_indicator_formatter('item_code',
function(doc) {
return (doc.docstatus==1 || doc.qty<=doc.actual_qty) ? "green" : "orange"

View File

@ -4,7 +4,19 @@
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
frappe.ui.form.on('Material Request', {
setup: function(frm) {
frm.custom_make_buttons = {
'Stock Entry': 'Issue Material',
'Purchase Order': 'Purchase Order',
'Request for Quotation': 'Request for Quotation',
'Supplier Quotation': 'Supplier Quotation',
'Production Order': 'Production Order'
}
},
onload: function(frm) {
// add item, if previous view was item
erpnext.utils.add_item(frm);
// formatter for material request item
frm.set_indicator_formatter('item_code',
function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange" }),
@ -71,7 +83,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
if(doc.material_request_type === "Manufacture" && doc.status === "Submitted")
cur_frm.add_custom_button(__("Production Order"),
this.raise_production_orders, __("Make"));
function() { me.raise_production_orders() }, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
@ -202,10 +214,16 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
},
raise_production_orders: function() {
var me = this;
frappe.call({
method:"erpnext.stock.doctype.material_request.material_request.raise_production_orders",
args: {
"material_request": cur_frm.doc.name
"material_request": me.frm.doc.name
},
callback: function(r) {
if(r.message.length) {
me.frm.reload_doc();
}
}
});
}

View File

@ -6,6 +6,12 @@
frappe.provide("erpnext.stock");
frappe.ui.form.on("Purchase Receipt", {
setup: function(frm) {
frm.custom_make_buttons = {
'Stock Entry': 'Return',
'Purchase Invoice': 'Invoice'
}
},
onload: function(frm) {
$.each(["warehouse", "rejected_warehouse"], function(i, field) {
frm.set_query(field, "items", function() {

View File

@ -66,6 +66,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
this.show_general_ledger();
}
erpnext.hide_company();
erpnext.utils.add_item(this.frm);
},
on_submit: function() {
@ -176,7 +177,6 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
excise.voucher_type = 'Excise Entry';
frappe.set_route('Form', 'Journal Entry', excise.name);
}, __("Make"));
cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
},
items_add: function(doc, cdt, cdn) {