From a117ef3cb88223f0a9f94f863e232b2771b277c8 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 28 Dec 2023 11:14:27 +0530 Subject: [PATCH] fix: not able to cancel sales invoice (#38979) --- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 4 +++- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 5 ++++- erpnext/public/js/controllers/transaction.js | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 215d8ec2153..44d4d816434 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -35,7 +35,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. super.onload(); // Ignore linked advances - this.frm.ignore_doctypes_on_cancel_all = ['Journal Entry', 'Payment Entry', 'Purchase Invoice', "Repost Payment Ledger", "Repost Accounting Ledger", "Unreconcile Payment", "Unreconcile Payment Entries"]; + this.frm.ignore_doctypes_on_cancel_all = ['Journal Entry', 'Payment Entry', 'Purchase Invoice', "Repost Payment Ledger", "Repost Accounting Ledger", "Unreconcile Payment", "Unreconcile Payment Entries", "Serial and Batch Bundle"]; if(!this.frm.doc.__islocal) { // show credit_to in print format @@ -408,6 +408,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. } on_submit() { + super.on_submit(); + $.each(this.frm.doc["items"] || [], function(i, row) { if(row.purchase_receipt) frappe.model.clear_doc("Purchase Receipt", row.purchase_receipt) }) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 6763e446a5d..c8d92d0d705 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -37,7 +37,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e super.onload(); this.frm.ignore_doctypes_on_cancel_all = ['POS Invoice', 'Timesheet', 'POS Invoice Merge Log', - 'POS Closing Entry', 'Journal Entry', 'Payment Entry', "Repost Payment Ledger", "Repost Accounting Ledger", "Unreconcile Payment", "Unreconcile Payment Entries"]; + 'POS Closing Entry', 'Journal Entry', 'Payment Entry', "Repost Payment Ledger", "Repost Accounting Ledger", "Unreconcile Payment", "Unreconcile Payment Entries", + 'Serial and Batch Bundle' + ]; if(!this.frm.doc.__islocal && !this.frm.doc.customer && this.frm.doc.debit_to) { // show debit_to in print format @@ -197,6 +199,7 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e on_submit(doc, dt, dn) { var me = this; + super.on_submit(); if (frappe.get_route()[0] != 'Form') { return } diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 39357834ed7..9427c380641 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -715,6 +715,11 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } on_submit() { + if (in_list(["Purchase Invoice", "Sales Invoice"], this.frm.doc.doctype) + && !this.frm.doc.update_stock) { + return; + } + this.refresh_serial_batch_bundle_field(); }