Merge pull request #40208 from barredterra/refactor-semgrep
refactor: reduce usage of `cur_frm`
This commit is contained in:
@@ -57,13 +57,13 @@ frappe.ui.form.on("Exchange Rate Revaluation", {
|
|||||||
get_entries: function (frm, account) {
|
get_entries: function (frm, account) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "get_accounts_data",
|
method: "get_accounts_data",
|
||||||
doc: cur_frm.doc,
|
doc: frm.doc,
|
||||||
account: account,
|
account: account,
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
frappe.model.clear_table(frm.doc, "accounts");
|
frappe.model.clear_table(frm.doc, "accounts");
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
r.message.forEach((d) => {
|
r.message.forEach((d) => {
|
||||||
cur_frm.add_child("accounts", d);
|
frm.add_child("accounts", d);
|
||||||
});
|
});
|
||||||
frm.events.get_total_gain_loss(frm);
|
frm.events.get_total_gain_loss(frm);
|
||||||
refresh_field("accounts");
|
refresh_field("accounts");
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ frappe.ui.form.on("Invoice Discounting", {
|
|||||||
|
|
||||||
show_general_ledger: (frm) => {
|
show_general_ledger: (frm) => {
|
||||||
if (frm.doc.docstatus > 0) {
|
if (frm.doc.docstatus > 0) {
|
||||||
cur_frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Accounting Ledger"),
|
__("Accounting Ledger"),
|
||||||
function () {
|
function () {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
|
|||||||
}
|
}
|
||||||
|
|
||||||
onload_post_render() {
|
onload_post_render() {
|
||||||
cur_frm.get_field("accounts").grid.set_multiple_add("account");
|
this.frm.get_field("accounts").grid.set_multiple_add("account");
|
||||||
}
|
}
|
||||||
|
|
||||||
load_defaults() {
|
load_defaults() {
|
||||||
@@ -402,7 +402,7 @@ erpnext.accounts.JournalEntry = class JournalEntry extends frappe.ui.form.Contro
|
|||||||
row.debit = -doc.difference;
|
row.debit = -doc.difference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_frm.cscript.update_totals(doc);
|
this.frm.cscript.update_totals(doc);
|
||||||
|
|
||||||
erpnext.accounts.dimensions.copy_dimension_from_first_row(this.frm, cdt, cdn, "accounts");
|
erpnext.accounts.dimensions.copy_dimension_from_first_row(this.frm, cdt, cdn, "accounts");
|
||||||
}
|
}
|
||||||
@@ -469,11 +469,11 @@ frappe.ui.form.on("Journal Entry Account", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
debit: function (frm, dt, dn) {
|
debit: function (frm, dt, dn) {
|
||||||
cur_frm.cscript.update_totals(frm.doc);
|
frm.cscript.update_totals(frm.doc);
|
||||||
},
|
},
|
||||||
|
|
||||||
credit: function (frm, dt, dn) {
|
credit: function (frm, dt, dn) {
|
||||||
cur_frm.cscript.update_totals(frm.doc);
|
frm.cscript.update_totals(frm.doc);
|
||||||
},
|
},
|
||||||
|
|
||||||
exchange_rate: function (frm, cdt, cdn) {
|
exchange_rate: function (frm, cdt, cdn) {
|
||||||
@@ -489,7 +489,7 @@ frappe.ui.form.on("Journal Entry Account", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.form.on("Journal Entry Account", "accounts_remove", function (frm) {
|
frappe.ui.form.on("Journal Entry Account", "accounts_remove", function (frm) {
|
||||||
cur_frm.cscript.update_totals(frm.doc);
|
frm.cscript.update_totals(frm.doc);
|
||||||
});
|
});
|
||||||
|
|
||||||
$.extend(erpnext.journal_entry, {
|
$.extend(erpnext.journal_entry, {
|
||||||
@@ -531,7 +531,7 @@ $.extend(erpnext.journal_entry, {
|
|||||||
flt(flt(row.credit_in_account_currency) * row.exchange_rate, precision("credit", row))
|
flt(flt(row.credit_in_account_currency) * row.exchange_rate, precision("credit", row))
|
||||||
);
|
);
|
||||||
|
|
||||||
cur_frm.cscript.update_totals(frm.doc);
|
frm.cscript.update_totals(frm.doc);
|
||||||
},
|
},
|
||||||
|
|
||||||
set_exchange_rate: function (frm, cdt, cdn) {
|
set_exchange_rate: function (frm, cdt, cdn) {
|
||||||
@@ -673,10 +673,10 @@ $.extend(erpnext.journal_entry, {
|
|||||||
return { filters: filters };
|
return { filters: filters };
|
||||||
},
|
},
|
||||||
|
|
||||||
reverse_journal_entry: function () {
|
reverse_journal_entry: function (frm) {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.accounts.doctype.journal_entry.journal_entry.make_reverse_journal_entry",
|
method: "erpnext.accounts.doctype.journal_entry.journal_entry.make_reverse_journal_entry",
|
||||||
frm: cur_frm,
|
frm: frm,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -322,13 +322,13 @@ frappe.ui.form.on("Payment Entry", {
|
|||||||
"references"
|
"references"
|
||||||
);
|
);
|
||||||
|
|
||||||
cur_frm.set_df_property(
|
frm.set_df_property(
|
||||||
"source_exchange_rate",
|
"source_exchange_rate",
|
||||||
"description",
|
"description",
|
||||||
"1 " + frm.doc.paid_from_account_currency + " = [?] " + company_currency
|
"1 " + frm.doc.paid_from_account_currency + " = [?] " + company_currency
|
||||||
);
|
);
|
||||||
|
|
||||||
cur_frm.set_df_property(
|
frm.set_df_property(
|
||||||
"target_exchange_rate",
|
"target_exchange_rate",
|
||||||
"description",
|
"description",
|
||||||
"1 " + frm.doc.paid_to_account_currency + " = [?] " + company_currency
|
"1 " + frm.doc.paid_to_account_currency + " = [?] " + company_currency
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ erpnext.selling.POSInvoiceController = class POSInvoiceController extends erpnex
|
|||||||
make_sales_return() {
|
make_sales_return() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.accounts.doctype.pos_invoice.pos_invoice.make_sales_return",
|
method: "erpnext.accounts.doctype.pos_invoice.pos_invoice.make_sales_return",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -293,7 +293,7 @@ frappe.ui.form.on("POS Invoice", {
|
|||||||
});
|
});
|
||||||
} else if (frappe.dom.freeze_count != 0) {
|
} else if (frappe.dom.freeze_count != 0) {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
cur_frm.reload_doc();
|
frm.reload_doc();
|
||||||
cur_pos.payment.events.submit_invoice();
|
cur_pos.payment.events.submit_invoice();
|
||||||
|
|
||||||
frappe.show_alert({
|
frappe.show_alert({
|
||||||
|
|||||||
@@ -131,17 +131,17 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
|
|
||||||
if (doc.docstatus == 1 && doc.outstanding_amount != 0 && !doc.on_hold) {
|
if (doc.docstatus == 1 && doc.outstanding_amount != 0 && !doc.on_hold) {
|
||||||
this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create"));
|
this.frm.add_custom_button(__("Payment"), () => this.make_payment_entry(), __("Create"));
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
this.frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doc.is_return && doc.docstatus == 1) {
|
if (!doc.is_return && doc.docstatus == 1) {
|
||||||
if (doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
|
if (doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
|
||||||
cur_frm.add_custom_button(__("Return / Debit Note"), this.make_debit_note, __("Create"));
|
this.frm.add_custom_button(__("Return / Debit Note"), this.make_debit_note, __("Create"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc.outstanding_amount > 0 && !cint(doc.is_return) && !doc.on_hold) {
|
if (doc.outstanding_amount > 0 && !cint(doc.is_return) && !doc.on_hold) {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Payment Request"),
|
__("Payment Request"),
|
||||||
function () {
|
function () {
|
||||||
me.make_payment_request();
|
me.make_payment_request();
|
||||||
@@ -462,7 +462,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
|
|||||||
make_debit_note() {
|
make_debit_note() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_debit_note",
|
method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_debit_note",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
refresh(doc, dt, dn) {
|
refresh(doc, dt, dn) {
|
||||||
const me = this;
|
const me = this;
|
||||||
super.refresh();
|
super.refresh();
|
||||||
if (cur_frm.msgbox && cur_frm.msgbox.$wrapper.is(":visible")) {
|
if (this.frm.msgbox && this.frm.msgbox.$wrapper.is(":visible")) {
|
||||||
// hide new msgbox
|
// hide new msgbox
|
||||||
cur_frm.msgbox.hide();
|
this.frm.msgbox.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.frm.toggle_reqd("due_date", !this.frm.doc.is_return);
|
this.frm.toggle_reqd("due_date", !this.frm.doc.is_return);
|
||||||
@@ -113,33 +113,33 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
if (doc.docstatus == 1 && !doc.is_return) {
|
if (doc.docstatus == 1 && !doc.is_return) {
|
||||||
var is_delivered_by_supplier = false;
|
var is_delivered_by_supplier = false;
|
||||||
|
|
||||||
is_delivered_by_supplier = cur_frm.doc.items.some(function (item) {
|
is_delivered_by_supplier = this.frm.doc.items.some(function (item) {
|
||||||
return item.is_delivered_by_supplier ? true : false;
|
return item.is_delivered_by_supplier ? true : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
|
if (doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
|
||||||
cur_frm.add_custom_button(__("Return / Credit Note"), this.make_sales_return, __("Create"));
|
this.frm.add_custom_button(__("Return / Credit Note"), this.make_sales_return, __("Create"));
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
this.frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cint(doc.update_stock) != 1) {
|
if (cint(doc.update_stock) != 1) {
|
||||||
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
|
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
|
||||||
var from_delivery_note = false;
|
var from_delivery_note = false;
|
||||||
from_delivery_note = cur_frm.doc.items.some(function (item) {
|
from_delivery_note = this.frm.doc.items.some(function (item) {
|
||||||
return item.delivery_note ? true : false;
|
return item.delivery_note ? true : false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!from_delivery_note && !is_delivered_by_supplier) {
|
if (!from_delivery_note && !is_delivered_by_supplier) {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Delivery"),
|
__("Delivery"),
|
||||||
cur_frm.cscript["Make Delivery Note"],
|
this.frm.cscript["Make Delivery Note"],
|
||||||
__("Create")
|
__("Create")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc.outstanding_amount > 0) {
|
if (doc.outstanding_amount > 0) {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Payment Request"),
|
__("Payment Request"),
|
||||||
function () {
|
function () {
|
||||||
me.make_payment_request();
|
me.make_payment_request();
|
||||||
@@ -147,10 +147,10 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
__("Create")
|
__("Create")
|
||||||
);
|
);
|
||||||
|
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Invoice Discounting"),
|
__("Invoice Discounting"),
|
||||||
function () {
|
function () {
|
||||||
cur_frm.events.create_invoice_discounting(cur_frm);
|
this.frm.events.create_invoice_discounting(this.frm);
|
||||||
},
|
},
|
||||||
__("Create")
|
__("Create")
|
||||||
);
|
);
|
||||||
@@ -171,10 +171,10 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (doc.docstatus === 1) {
|
if (doc.docstatus === 1) {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Maintenance Schedule"),
|
__("Maintenance Schedule"),
|
||||||
function () {
|
function () {
|
||||||
cur_frm.cscript.make_maintenance_schedule();
|
this.frm.cscript.make_maintenance_schedule();
|
||||||
},
|
},
|
||||||
__("Create")
|
__("Create")
|
||||||
);
|
);
|
||||||
@@ -182,7 +182,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show buttons only when pos view is active
|
// Show buttons only when pos view is active
|
||||||
if (cint(doc.docstatus == 0) && cur_frm.page.current_view_name !== "pos" && !doc.is_return) {
|
if (cint(doc.docstatus == 0) && this.frm.page.current_view_name !== "pos" && !doc.is_return) {
|
||||||
this.frm.cscript.sales_order_btn();
|
this.frm.cscript.sales_order_btn();
|
||||||
this.frm.cscript.delivery_note_btn();
|
this.frm.cscript.delivery_note_btn();
|
||||||
this.frm.cscript.quotation_btn();
|
this.frm.cscript.quotation_btn();
|
||||||
@@ -213,7 +213,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
make_maintenance_schedule() {
|
make_maintenance_schedule() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
|
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,28 +232,27 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
|
|
||||||
set_default_print_format() {
|
set_default_print_format() {
|
||||||
// set default print format to POS type or Credit Note
|
// set default print format to POS type or Credit Note
|
||||||
if (cur_frm.doc.is_pos) {
|
if (this.frm.doc.is_pos) {
|
||||||
if (cur_frm.pos_print_format) {
|
if (this.frm.pos_print_format) {
|
||||||
cur_frm.meta._default_print_format = cur_frm.meta.default_print_format;
|
this.frm.meta._default_print_format = this.frm.meta.default_print_format;
|
||||||
cur_frm.meta.default_print_format = cur_frm.pos_print_format;
|
this.frm.meta.default_print_format = this.frm.pos_print_format;
|
||||||
}
|
}
|
||||||
} else if (cur_frm.doc.is_return && !cur_frm.meta.default_print_format) {
|
} else if (this.frm.doc.is_return && !this.frm.meta.default_print_format) {
|
||||||
if (cur_frm.return_print_format) {
|
if (this.frm.return_print_format) {
|
||||||
cur_frm.meta._default_print_format = cur_frm.meta.default_print_format;
|
this.frm.meta._default_print_format = this.frm.meta.default_print_format;
|
||||||
cur_frm.meta.default_print_format = cur_frm.return_print_format;
|
this.frm.meta.default_print_format = this.frm.return_print_format;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cur_frm.meta._default_print_format) {
|
if (this.frm.meta._default_print_format) {
|
||||||
cur_frm.meta.default_print_format = cur_frm.meta._default_print_format;
|
this.frm.meta.default_print_format = this.frm.meta._default_print_format;
|
||||||
cur_frm.meta._default_print_format = null;
|
this.frm.meta._default_print_format = null;
|
||||||
} else if (
|
} else if (
|
||||||
in_list(
|
[this.frm.pos_print_format, this.frm.return_print_format].includes(
|
||||||
[cur_frm.pos_print_format, cur_frm.return_print_format],
|
this.frm.meta.default_print_format
|
||||||
cur_frm.meta.default_print_format
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
cur_frm.meta.default_print_format = null;
|
this.frm.meta.default_print_format = null;
|
||||||
cur_frm.meta._default_print_format = null;
|
this.frm.meta._default_print_format = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,7 +464,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
|||||||
make_sales_return() {
|
make_sales_return() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_sales_return",
|
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_sales_return",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ frappe.ui.form.on("Asset", {
|
|||||||
method: "erpnext.assets.doctype.asset.asset.make_asset_movement",
|
method: "erpnext.assets.doctype.asset.asset.make_asset_movement",
|
||||||
freeze: true,
|
freeze: true,
|
||||||
args: {
|
args: {
|
||||||
assets: [{ name: cur_frm.doc.name }],
|
assets: [{ name: frm.doc.name }],
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
@@ -791,9 +791,7 @@ erpnext.asset.scrap_asset = function (frm) {
|
|||||||
asset_name: frm.doc.name,
|
asset_name: frm.doc.name,
|
||||||
},
|
},
|
||||||
method: "erpnext.assets.doctype.asset.depreciation.scrap_asset",
|
method: "erpnext.assets.doctype.asset.depreciation.scrap_asset",
|
||||||
callback: function (r) {
|
callback: (r) => frm.reload_doc(),
|
||||||
cur_frm.reload_doc();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -805,19 +803,17 @@ erpnext.asset.restore_asset = function (frm) {
|
|||||||
asset_name: frm.doc.name,
|
asset_name: frm.doc.name,
|
||||||
},
|
},
|
||||||
method: "erpnext.assets.doctype.asset.depreciation.restore_asset",
|
method: "erpnext.assets.doctype.asset.depreciation.restore_asset",
|
||||||
callback: function (r) {
|
callback: (r) => frm.reload_doc(),
|
||||||
cur_frm.reload_doc();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
erpnext.asset.transfer_asset = function () {
|
erpnext.asset.transfer_asset = function (frm) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.assets.doctype.asset.asset.make_asset_movement",
|
method: "erpnext.assets.doctype.asset.asset.make_asset_movement",
|
||||||
freeze: true,
|
freeze: true,
|
||||||
args: {
|
args: {
|
||||||
assets: [{ name: cur_frm.doc.name }],
|
assets: [{ name: frm.doc.name }],
|
||||||
purpose: "Transfer",
|
purpose: "Transfer",
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ frappe.ui.form.on("Purchase Order", {
|
|||||||
args: {
|
args: {
|
||||||
subcontract_order: frm.doc.name,
|
subcontract_order: frm.doc.name,
|
||||||
rm_details: po_details,
|
rm_details: po_details,
|
||||||
order_doctype: cur_frm.doc.doctype,
|
order_doctype: frm.doc.doctype,
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
if (r && r.message) {
|
if (r && r.message) {
|
||||||
@@ -270,8 +270,8 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
var allow_receipt = false;
|
var allow_receipt = false;
|
||||||
var is_drop_ship = false;
|
var is_drop_ship = false;
|
||||||
|
|
||||||
for (var i in cur_frm.doc.items) {
|
for (var i in this.frm.doc.items) {
|
||||||
var item = cur_frm.doc.items[i];
|
var item = this.frm.doc.items[i];
|
||||||
if (item.delivered_by_supplier !== 1) {
|
if (item.delivered_by_supplier !== 1) {
|
||||||
allow_receipt = true;
|
allow_receipt = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -348,7 +348,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
if (doc.status != "Closed") {
|
if (doc.status != "Closed") {
|
||||||
if (doc.status != "On Hold") {
|
if (doc.status != "On Hold") {
|
||||||
if (flt(doc.per_received, 2) < 100 && allow_receipt) {
|
if (flt(doc.per_received, 2) < 100 && allow_receipt) {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Purchase Receipt"),
|
__("Purchase Receipt"),
|
||||||
this.make_purchase_receipt,
|
this.make_purchase_receipt,
|
||||||
__("Create")
|
__("Create")
|
||||||
@@ -356,7 +356,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
if (doc.is_subcontracted) {
|
if (doc.is_subcontracted) {
|
||||||
if (doc.is_old_subcontracting_flow) {
|
if (doc.is_old_subcontracting_flow) {
|
||||||
if (me.has_unsupplied_items()) {
|
if (me.has_unsupplied_items()) {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Material to Supplier"),
|
__("Material to Supplier"),
|
||||||
function () {
|
function () {
|
||||||
me.make_stock_entry();
|
me.make_stock_entry();
|
||||||
@@ -365,7 +365,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Subcontracting Order"),
|
__("Subcontracting Order"),
|
||||||
this.make_subcontracting_order,
|
this.make_subcontracting_order,
|
||||||
__("Create")
|
__("Create")
|
||||||
@@ -374,7 +374,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flt(doc.per_billed, 2) < 100)
|
if (flt(doc.per_billed, 2) < 100)
|
||||||
cur_frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Purchase Invoice"),
|
__("Purchase Invoice"),
|
||||||
this.make_purchase_invoice,
|
this.make_purchase_invoice,
|
||||||
__("Create")
|
__("Create")
|
||||||
@@ -418,10 +418,10 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
this.frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
}
|
}
|
||||||
} else if (doc.docstatus === 0) {
|
} else if (doc.docstatus === 0) {
|
||||||
cur_frm.cscript.add_from_mappers();
|
this.frm.cscript.add_from_mappers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,8 +458,8 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.controllers.subcontracting_controller.make_rm_stock_entry",
|
method: "erpnext.controllers.subcontracting_controller.make_rm_stock_entry",
|
||||||
args: {
|
args: {
|
||||||
subcontract_order: cur_frm.doc.name,
|
subcontract_order: this.frm.doc.name,
|
||||||
order_doctype: cur_frm.doc.doctype,
|
order_doctype: this.frm.doc.doctype,
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
var doclist = frappe.model.sync(r.message);
|
var doclist = frappe.model.sync(r.message);
|
||||||
@@ -478,7 +478,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
make_purchase_receipt() {
|
make_purchase_receipt() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_receipt",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
freeze_message: __("Creating Purchase Receipt ..."),
|
freeze_message: __("Creating Purchase Receipt ..."),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -486,14 +486,14 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
make_purchase_invoice() {
|
make_purchase_invoice() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
make_subcontracting_order() {
|
make_subcontracting_order() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_subcontracting_order",
|
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_subcontracting_order",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
freeze_message: __("Creating Subcontracting Order ..."),
|
freeze_message: __("Creating Subcontracting Order ..."),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -652,7 +652,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
|
|
||||||
unhold_purchase_order() {
|
unhold_purchase_order() {
|
||||||
cur_frm.cscript.update_status("Resume", "Draft");
|
this.frm.cscript.update_status("Resume", "Draft");
|
||||||
}
|
}
|
||||||
|
|
||||||
hold_purchase_order() {
|
hold_purchase_order() {
|
||||||
@@ -692,15 +692,15 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
|
|
||||||
unclose_purchase_order() {
|
unclose_purchase_order() {
|
||||||
cur_frm.cscript.update_status("Re-open", "Submitted");
|
this.frm.cscript.update_status("Re-open", "Submitted");
|
||||||
}
|
}
|
||||||
|
|
||||||
close_purchase_order() {
|
close_purchase_order() {
|
||||||
cur_frm.cscript.update_status("Close", "Closed");
|
this.frm.cscript.update_status("Close", "Closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
delivered_by_supplier() {
|
delivered_by_supplier() {
|
||||||
cur_frm.cscript.update_status("Deliver", "Delivered");
|
this.frm.cscript.update_status("Deliver", "Delivered");
|
||||||
}
|
}
|
||||||
|
|
||||||
items_on_form_rendered() {
|
items_on_form_rendered() {
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ erpnext.buying.SupplierQuotationController = class SupplierQuotationController e
|
|||||||
this.frm.set_value("valid_till", frappe.datetime.add_months(this.frm.doc.transaction_date, 1));
|
this.frm.set_value("valid_till", frappe.datetime.add_months(this.frm.doc.transaction_date, 1));
|
||||||
}
|
}
|
||||||
if (this.frm.doc.docstatus === 1) {
|
if (this.frm.doc.docstatus === 1) {
|
||||||
cur_frm.add_custom_button(__("Purchase Order"), this.make_purchase_order, __("Create"));
|
this.frm.add_custom_button(__("Purchase Order"), this.make_purchase_order, __("Create"));
|
||||||
cur_frm.page.set_inner_btn_group_as_primary(__("Create"));
|
this.frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
cur_frm.add_custom_button(__("Quotation"), this.make_quotation, __("Create"));
|
this.frm.add_custom_button(__("Quotation"), this.make_quotation, __("Create"));
|
||||||
} else if (this.frm.doc.docstatus === 0) {
|
} else if (this.frm.doc.docstatus === 0) {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Material Request"),
|
__("Material Request"),
|
||||||
@@ -87,13 +87,13 @@ erpnext.buying.SupplierQuotationController = class SupplierQuotationController e
|
|||||||
make_purchase_order() {
|
make_purchase_order() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
make_quotation() {
|
make_quotation() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_quotation",
|
method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_quotation",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ frappe.ui.form.on("Campaign", {
|
|||||||
frappe.boot.sysdefaults.campaign_naming_by == "Naming Series"
|
frappe.boot.sysdefaults.campaign_naming_by == "Naming Series"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
cur_frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("View Leads"),
|
__("View Leads"),
|
||||||
function () {
|
function () {
|
||||||
frappe.route_options = { source: "Campaign", campaign_name: frm.doc.name };
|
frappe.route_options = { source: "Campaign", campaign_name: frm.doc.name };
|
||||||
|
|||||||
@@ -89,32 +89,33 @@ erpnext.LeadController = class LeadController extends frappe.ui.form.Controller
|
|||||||
make_customer() {
|
make_customer() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.lead.lead.make_customer",
|
method: "erpnext.crm.doctype.lead.lead.make_customer",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
make_quotation() {
|
make_quotation() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.lead.lead.make_quotation",
|
method: "erpnext.crm.doctype.lead.lead.make_quotation",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
make_prospect() {
|
make_prospect() {
|
||||||
|
const me = this;
|
||||||
frappe.model.with_doctype("Prospect", function () {
|
frappe.model.with_doctype("Prospect", function () {
|
||||||
let prospect = frappe.model.get_new_doc("Prospect");
|
let prospect = frappe.model.get_new_doc("Prospect");
|
||||||
prospect.company_name = cur_frm.doc.company_name;
|
prospect.company_name = me.frm.doc.company_name;
|
||||||
prospect.no_of_employees = cur_frm.doc.no_of_employees;
|
prospect.no_of_employees = me.frm.doc.no_of_employees;
|
||||||
prospect.industry = cur_frm.doc.industry;
|
prospect.industry = me.frm.doc.industry;
|
||||||
prospect.market_segment = cur_frm.doc.market_segment;
|
prospect.market_segment = me.frm.doc.market_segment;
|
||||||
prospect.territory = cur_frm.doc.territory;
|
prospect.territory = me.frm.doc.territory;
|
||||||
prospect.fax = cur_frm.doc.fax;
|
prospect.fax = me.frm.doc.fax;
|
||||||
prospect.website = cur_frm.doc.website;
|
prospect.website = me.frm.doc.website;
|
||||||
prospect.prospect_owner = cur_frm.doc.lead_owner;
|
prospect.prospect_owner = me.frm.doc.lead_owner;
|
||||||
prospect.notes = cur_frm.doc.notes;
|
prospect.notes = me.frm.doc.notes;
|
||||||
|
|
||||||
let leads_row = frappe.model.add_child(prospect, "leads");
|
let leads_row = frappe.model.add_child(prospect, "leads");
|
||||||
leads_row.lead = cur_frm.doc.name;
|
leads_row.lead = me.frm.doc.name;
|
||||||
|
|
||||||
frappe.set_route("Form", "Prospect", prospect.name);
|
frappe.set_route("Form", "Prospect", prospect.name);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -318,14 +318,14 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller {
|
|||||||
create_quotation() {
|
create_quotation() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
|
method: "erpnext.crm.doctype.opportunity.opportunity.make_quotation",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
make_customer() {
|
make_customer() {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.crm.doctype.opportunity.opportunity.make_customer",
|
method: "erpnext.crm.doctype.opportunity.opportunity.make_customer",
|
||||||
frm: cur_frm,
|
frm: this.frm,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2267,9 +2267,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_method_for_payment() {
|
get_method_for_payment() {
|
||||||
var method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
|
let method = "erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry";
|
||||||
if(cur_frm.doc.__onload && cur_frm.doc.__onload.make_payment_via_journal_entry){
|
if(this.frm.doc.__onload && this.frm.doc.__onload.make_payment_via_journal_entry){
|
||||||
if(['Sales Invoice', 'Purchase Invoice'].includes( cur_frm.doc.doctype)){
|
if(['Sales Invoice', 'Purchase Invoice'].includes( this.frm.doc.doctype)){
|
||||||
method = "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_invoice";
|
method = "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_invoice";
|
||||||
}else {
|
}else {
|
||||||
method= "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_order";
|
method= "erpnext.accounts.doctype.journal_entry.journal_entry.get_payment_entry_against_order";
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ erpnext.timesheet.control_timer = function (frm, dialog, row, timestamp = 0) {
|
|||||||
|
|
||||||
// Stop the timer and update the time logged by the timer on click of 'Complete' button
|
// Stop the timer and update the time logged by the timer on click of 'Complete' button
|
||||||
$btn_complete.click(function () {
|
$btn_complete.click(function () {
|
||||||
var grid_row = cur_frm.fields_dict["time_logs"].grid.get_row(row.idx - 1);
|
var grid_row = frm.fields_dict["time_logs"].grid.get_row(row.idx - 1);
|
||||||
var args = dialog.get_values();
|
var args = dialog.get_values();
|
||||||
grid_row.doc.completed = 1;
|
grid_row.doc.completed = 1;
|
||||||
grid_row.doc.activity_type = args.activity_type;
|
grid_row.doc.activity_type = args.activity_type;
|
||||||
|
|||||||
Reference in New Issue
Block a user