chore: Remove cur_frm from sales_invoice.js

This commit is contained in:
Deepesh Garg 2023-07-23 22:44:18 +05:30
parent 8d3d9493f0
commit cdc9b62688
4 changed files with 9 additions and 12 deletions

View File

@ -1,7 +1,7 @@
frappe.ui.form.on("Sales Invoice", { frappe.ui.form.on("Sales Invoice", {
refresh: (frm) => { refresh: (frm) => {
if(frm.doc.docstatus == 1) { if(frm.doc.docstatus == 1) {
frm.add_custom_button('Generate E-Invoice', () => { frm.add_custom_button(__('Generate E-Invoice'), () => {
frm.call({ frm.call({
method: "erpnext.regional.italy.utils.generate_single_invoice", method: "erpnext.regional.italy.utils.generate_single_invoice",
args: { args: {

View File

@ -1,9 +1,6 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.provide("erpnext.crm"); frappe.provide("erpnext.crm");
cur_frm.email_field = "contact_email";
erpnext.pre_sales.set_as_lost("Quotation"); erpnext.pre_sales.set_as_lost("Quotation");
erpnext.sales_common.setup_selling_controller(); erpnext.sales_common.setup_selling_controller();
@ -22,6 +19,8 @@ frappe.ui.form.on("Opportunity", {
} }
} }
}); });
frm.email_field = "contact_email";
}, },
validate: function(frm) { validate: function(frm) {

View File

@ -2,8 +2,6 @@
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
frappe.provide("erpnext.buying"); frappe.provide("erpnext.buying");
// cur_frm.email_field = "contact_email";
// cur_frm.add_fetch('project', 'cost_center', 'cost_center'); // cur_frm.add_fetch('project', 'cost_center', 'cost_center');
erpnext.buying = { erpnext.buying = {
@ -11,6 +9,7 @@ erpnext.buying = {
erpnext.buying.BuyingController = class BuyingController extends erpnext.TransactionController { erpnext.buying.BuyingController = class BuyingController extends erpnext.TransactionController {
setup() { setup() {
super.setup(); super.setup();
this.frm.email_field = "contact_email";
} }
onload(doc, cdt, cdn) { onload(doc, cdt, cdn) {

View File

@ -1,8 +1,6 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
// cur_frm.email_field = "contact_email";
frappe.provide("erpnext.selling"); frappe.provide("erpnext.selling");
erpnext.sales_common = { erpnext.sales_common = {
@ -10,6 +8,7 @@ erpnext.sales_common = {
erpnext.selling.SellingController = class SellingController extends erpnext.TransactionController { erpnext.selling.SellingController = class SellingController extends erpnext.TransactionController {
setup() { setup() {
super.setup(); super.setup();
this.frm.email_field = "contact_email";
} }
onload() { onload() {
@ -61,7 +60,7 @@ erpnext.sales_common = {
this.frm.set_query("item_code", "items", function() { this.frm.set_query("item_code", "items", function() {
return { return {
query: "erpnext.controllers.queries.item_query", query: "erpnext.controllers.queries.item_query",
filters: {'is_sales_item': 1, 'customer': cur_frm.doc.customer, 'has_variants': 0} filters: {'is_sales_item': 1, 'customer': me.frm.doc.customer, 'has_variants': 0}
} }
}); });
} }
@ -260,9 +259,9 @@ erpnext.sales_common = {
} }
set_product_bundle_help(doc) { set_product_bundle_help(doc) {
if(!cur_frm.fields_dict.packing_list) return; if(!this.frm.fields_dict.packing_list) return;
if ((doc.packed_items || []).length) { if ((doc.packed_items || []).length) {
$(cur_frm.fields_dict.packing_list.row.wrapper).toggle(true); $(this.frm.fields_dict.packing_list.row.wrapper).toggle(true);
if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
var help_msg = "<div class='alert alert-warning'>" + var help_msg = "<div class='alert alert-warning'>" +
@ -271,7 +270,7 @@ erpnext.sales_common = {
frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = help_msg; frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = help_msg;
} }
} else { } else {
$(cur_frm.fields_dict.packing_list.row.wrapper).toggle(false); $(this.frm.fields_dict.packing_list.row.wrapper).toggle(false);
if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = ''; frappe.meta.get_docfield(doc.doctype, 'product_bundle_help', doc.name).options = '';
} }