[fix] remove first row on mapping, fixes #5707
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 444c3b5..c655626 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -47,7 +47,7 @@
if(doc.docstatus===0) {
cur_frm.add_custom_button(__('Purchase Order'), function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
source_doctype: "Purchase Order",
get_query_filters: {
@@ -61,7 +61,7 @@
}, __("Get items from"));
cur_frm.add_custom_button(__('Purchase Receipt'), function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
source_doctype: "Purchase Receipt",
get_query_filters: {
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 1d48df0..64379a1 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -101,7 +101,7 @@
sales_order_btn: function() {
this.$sales_order_btn = cur_frm.add_custom_button(__('Sales Order'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
get_query_filters: {
@@ -118,7 +118,7 @@
delivery_note_btn: function() {
this.$delivery_note_btn = cur_frm.add_custom_button(__('Delivery Note'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note",
get_query: function() {
diff --git a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py
index 07ab969..d9bac3c 100644
--- a/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py
+++ b/erpnext/accounts/report/bank_clearance_summary/bank_clearance_summary.py
@@ -8,43 +8,43 @@
def execute(filters=None):
if not filters: filters = {}
-
+
columns = get_columns()
data = get_entries(filters)
-
+
return columns, data
-
+
def get_columns():
return [
- _("Payment Document") + ":Link/DocType:130",
- _("Payment Entry") + ":Dynamic Link/"+_("Payment Document")+":110",
- _("Posting Date") + ":Date:100",
+ _("Payment Document") + ":Link/DocType:130",
+ _("Payment Entry") + ":Dynamic Link/"+_("Payment Document")+":110",
+ _("Posting Date") + ":Date:100",
_("Cheque/Reference No") + "::120",
- _("Clearance Date") + ":Date:100",
- _("Against Account") + ":Link/Account:170",
+ _("Clearance Date") + ":Date:100",
+ _("Against Account") + ":Link/Account:170",
_("Amount") + ":Currency:120"
]
def get_conditions(filters):
conditions = ""
-
+
if filters.get("from_date"): conditions += " and posting_date>=%(from_date)s"
if filters.get("to_date"): conditions += " and posting_date<=%(to_date)s"
-
+
return conditions
-
+
def get_entries(filters):
conditions = get_conditions(filters)
- journal_entries = frappe.db.sql("""select "Journal Entry", jv.name, jv.posting_date,
+ journal_entries = frappe.db.sql("""select "Journal Entry", jv.name, jv.posting_date,
jv.cheque_no, jv.clearance_date, jvd.against_account, (jvd.debit - jvd.credit)
- from `tabJournal Entry Account` jvd, `tabJournal Entry` jv
+ from `tabJournal Entry Account` jvd, `tabJournal Entry` jv
where jvd.parent = jv.name and jv.docstatus=1 and jvd.account = %(account)s {0}
order by posting_date DESC, jv.name DESC""".format(conditions), filters, as_list=1)
-
- payment_entries = frappe.db.sql("""select "Payment Entry", name, posting_date,
+
+ payment_entries = frappe.db.sql("""select "Payment Entry", name, posting_date,
reference_no, clearance_date, party, if(paid_from=%(account)s, paid_amount, received_amount)
from `tabPayment Entry`
where docstatus=1 and (paid_from = %(account)s or paid_to = %(account)s) {0}
- order by posting_date DESC, name DESC""".format(conditions), filters, as_list=1, debug=1)
-
+ order by posting_date DESC, name DESC""".format(conditions), filters, as_list=1)
+
return sorted(journal_entries + payment_entries, key=lambda k: k[2] or getdate(nowdate()))
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 9624967..15356fd 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -87,7 +87,7 @@
},
get_items_from_open_material_requests: function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order_based_on_supplier",
source_name: this.frm.doc.supplier,
get_query_filters: {
@@ -150,7 +150,7 @@
add_from_mappers: function() {
cur_frm.add_custom_button(__('Material Request'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order",
source_doctype: "Material Request",
get_query_filters: {
@@ -165,7 +165,7 @@
cur_frm.add_custom_button(__('Supplier Quotation'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
source_doctype: "Supplier Quotation",
get_query_filters: {
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
index 9a81467..ce1c088 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.js
@@ -135,7 +135,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Material Request'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.material_request.material_request.make_request_for_quotation",
source_doctype: "Material Request",
get_query_filters: {
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index b3030f7..1859cf5 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -15,7 +15,7 @@
else if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Material Request'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.material_request.material_request.make_supplier_quotation",
source_doctype: "Material Request",
get_query_filters: {
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index 9144692..21a7429 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -128,7 +128,7 @@
cur_frm.cscript.lead = function(doc, cdt, cdn) {
cur_frm.toggle_display("contact_info", doc.customer || doc.lead);
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity",
source_name: cur_frm.doc.lead,
frm: cur_frm
diff --git a/erpnext/hr/doctype/appraisal/appraisal.js b/erpnext/hr/doctype/appraisal/appraisal.js
index 4cfcd7e..728e5c2 100644
--- a/erpnext/hr/doctype/appraisal/appraisal.js
+++ b/erpnext/hr/doctype/appraisal/appraisal.js
@@ -24,7 +24,7 @@
}
cur_frm.cscript.kra_template = function(doc, dt, dn) {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.hr.doctype.appraisal.appraisal.fetch_appraisal_template",
source_name: cur_frm.doc.kra_template,
frm: cur_frm
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
index cf0ee51..bcf1ae6 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
@@ -20,7 +20,7 @@
if (this.frm.doc.docstatus === 0) {
this.frm.add_custom_button(__('Sales Order'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_schedule",
source_doctype: "Sales Order",
get_query_filters: {
diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
index 5615886..38c20da 100644
--- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
+++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
@@ -19,7 +19,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Maintenance Schedule'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
source_doctype: "Maintenance Schedule",
get_query_filters: {
@@ -31,7 +31,7 @@
}, __("Get items from"));
cur_frm.add_custom_button(__('Warranty Claim'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.support.doctype.warranty_claim.warranty_claim.make_maintenance_visit",
source_doctype: "Warranty Claim",
get_query_filters: {
@@ -43,7 +43,7 @@
}, __("Get items from"));
cur_frm.add_custom_button(__('Sales Order'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
source_doctype: "Sales Order",
get_query_filters: {
diff --git a/erpnext/patches/v7_0/make_is_group_fieldtype_as_check.py b/erpnext/patches/v7_0/make_is_group_fieldtype_as_check.py
index eab4401..aef0306 100644
--- a/erpnext/patches/v7_0/make_is_group_fieldtype_as_check.py
+++ b/erpnext/patches/v7_0/make_is_group_fieldtype_as_check.py
@@ -8,6 +8,6 @@
#In MySQL, you can't modify the same table which you use in the SELECT part.
frappe.db.sql(""" update `tab{doctype}` set is_group = 1
- where name in (select parent_{field} from (select distinct parent_{field} from `tab{doctype}`
+ where name in (select parent_{field} from (select distinct parent_{field} from `tab{doctype}`
where parent_{field} != '') as dummy_table)
- """.format(doctype=doctype, field=doctype.strip().lower().replace(' ','_')), debug=1)
+ """.format(doctype=doctype, field=doctype.strip().lower().replace(' ','_')))
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index ea28fd5..d347227 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -120,6 +120,65 @@
}
});
+erpnext.utils.map_current_doc = function(opts) {
+ if(opts.get_query_filters) {
+ opts.get_query = function() {
+ return {filters: opts.get_query_filters};
+ }
+ }
+ var _map = function() {
+ // remove first item row if empty
+ if($.isArray(cur_frm.doc.items)) {
+ if(!cur_frm.doc.items[0].item_code) {
+ cur_frm.doc.items = cur_frm.doc.items.splice(1);
+ }
+ }
+
+ return frappe.call({
+ // Sometimes we hit the limit for URL length of a GET request
+ // as we send the full target_doc. Hence this is a POST request.
+ type: "POST",
+ method: opts.method,
+ args: {
+ "source_name": opts.source_name,
+ "target_doc": cur_frm.doc
+ },
+ callback: function(r) {
+ if(!r.exc) {
+ var doc = frappe.model.sync(r.message);
+ cur_frm.refresh();
+ }
+ }
+ });
+ }
+ if(opts.source_doctype) {
+ var d = new frappe.ui.Dialog({
+ title: __("Get From ") + __(opts.source_doctype),
+ fields: [
+ {
+ fieldtype: "Link",
+ label: __(opts.source_doctype),
+ fieldname: opts.source_doctype,
+ options: opts.source_doctype,
+ get_query: opts.get_query,
+ reqd:1
+ },
+ ]
+ });
+ d.set_primary_action(__('Get Items'), function() {
+ var values = d.get_values();
+ if(!values)
+ return;
+ opts.source_name = values[opts.source_doctype];
+ d.hide();
+ _map();
+ })
+ d.show();
+ } else if(opts.source_name) {
+ _map();
+ }
+}
+
// add description on posting time
$(document).on('app_ready', function() {
if(!frappe.datetime.is_timezone_same()) {
diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js
index 09deea2..5b99691 100644
--- a/erpnext/selling/doctype/installation_note/installation_note.js
+++ b/erpnext/selling/doctype/installation_note/installation_note.js
@@ -49,7 +49,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('From Delivery Note'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_installation_note",
source_doctype: "Delivery Note",
get_query_filters: {
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index f61f0e9..d111c14 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -29,7 +29,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Opportunity'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
source_doctype: "Opportunity",
get_query_filters: {
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index d8ed591..f1eeccc 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -97,7 +97,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Quotation'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",
source_doctype: "Quotation",
get_query_filters: {
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index ab8297c..65658d6 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -37,7 +37,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Sales Order'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_delivery_note",
source_doctype: "Sales Order",
get_query_filters: {
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 0a07582..bbd312d 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -87,7 +87,7 @@
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('Sales Order'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request",
source_doctype: "Sales Order",
get_query_filters: {
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index f622b63..792f269 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -52,7 +52,7 @@
if(this.frm.doc.docstatus==0) {
cur_frm.add_custom_button(__('Purchase Order'),
function() {
- frappe.model.map_current_doc({
+ erpnext.utils.map_current_doc({
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
source_doctype: "Purchase Order",
get_query_filters: {