From 9a12545ac3fcf50d7dabf86fcf156433802708d3 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Sat, 10 Jun 2023 12:33:06 +0530 Subject: [PATCH 01/11] fix(ux): add filter `disabled=0` for batch no --- .../doctype/serial_and_batch_bundle/serial_and_batch_bundle.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js index d50bdba3c9..2e23bc3887 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js @@ -194,6 +194,7 @@ frappe.ui.form.on('Serial and Batch Bundle', { return { filters: { item: frm.doc.item_code, + disabled: 0, } }; }); From 0b009da1225585d235243e7b1015a760f32d04c0 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Sun, 11 Jun 2023 20:14:59 +0530 Subject: [PATCH 02/11] fix(ux): only list related DocTypes --- .../serial_and_batch_bundle.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js index 2e23bc3887..cda444510a 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js @@ -161,6 +161,23 @@ frappe.ui.form.on('Serial and Batch Bundle', { 'istable': 0, 'issingle': 0, 'is_submittable': 1, + 'name': ['in', [ + "Asset Capitalization", + "Asset Repair", + "Delivery Note", + "Installation Note", + "Job Card", + "Maintenance Schedule", + "POS Invoice", + "Pick List", + "Purchase Invoice", + "Purchase Receipt", + "Quotation", + "Sales Invoice", + "Stock Entry", + "Stock Reconciliation", + "Subcontracting Receipt", + ]], } }; }); From c6acb0d2006455a8181e1e1844a2b172288cea4d Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Sun, 11 Jun 2023 22:04:08 +0530 Subject: [PATCH 03/11] fix: DocType not found --- .../serial_and_batch_bundle.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index cc55bd6ea8..7aca791fe1 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -563,9 +563,16 @@ class SerialandBatchBundle(Document): @property def child_table(self): + parent_child_map = { + "Asset Capitalization": "Asset Capitalization Stock Item", + "Asset Repair": "Asset Repair Consumed Item", + "Quotation": "Packed Item", + "Stock Entry": "Stock Entry Detail", + } + table = f"{self.voucher_type} Item" - if self.voucher_type == "Stock Entry": - table = f"{self.voucher_type} Detail" + if self.voucher_type in parent_child_map: + table = parent_child_map[self.voucher_type] return table From c9923e49969f7aa4e05dda8e2c403f5542644762 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Sun, 11 Jun 2023 22:08:46 +0530 Subject: [PATCH 04/11] fix: 'NoneType' object has no attribute 'precision' --- .../serial_and_batch_bundle.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 7aca791fe1..9a4206a03b 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -122,7 +122,11 @@ class SerialandBatchBundle(Document): frappe.throw(_(message), exception, title=_("Error")) def set_incoming_rate(self, row=None, save=False): - if self.type_of_transaction not in ["Inward", "Outward"]: + if self.type_of_transaction not in ["Inward", "Outward"] or self.voucher_type in [ + "Installation Note", + "Maintenance Schedule", + "Pick List", + ]: return if self.type_of_transaction == "Outward": @@ -220,7 +224,7 @@ class SerialandBatchBundle(Document): def set_incoming_rate_for_inward_transaction(self, row=None, save=False): valuation_field = "valuation_rate" - if self.voucher_type in ["Sales Invoice", "Delivery Note"]: + if self.voucher_type in ["Sales Invoice", "Delivery Note", "Quotation"]: valuation_field = "incoming_rate" if self.voucher_type == "POS Invoice": @@ -229,8 +233,10 @@ class SerialandBatchBundle(Document): rate = row.get(valuation_field) if row else 0.0 child_table = self.child_table - if self.voucher_type == "Subcontracting Receipt" and self.voucher_detail_no: - if frappe.db.exists("Subcontracting Receipt Supplied Item", self.voucher_detail_no): + if self.voucher_type == "Subcontracting Receipt": + if not self.voucher_detail_no: + return + elif frappe.db.exists("Subcontracting Receipt Supplied Item", self.voucher_detail_no): valuation_field = "rate" child_table = "Subcontracting Receipt Supplied Item" else: From fe054508f12678236986ea3cf867b12c7f4bcde2 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Wed, 14 Jun 2023 15:04:36 +0530 Subject: [PATCH 05/11] fix: 'NoneType' object has no attribute 'precision' for Job Card --- .../serial_and_batch_bundle.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 9a4206a03b..57bb71ef1e 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -124,6 +124,7 @@ class SerialandBatchBundle(Document): def set_incoming_rate(self, row=None, save=False): if self.type_of_transaction not in ["Inward", "Outward"] or self.voucher_type in [ "Installation Note", + "Job Card", "Maintenance Schedule", "Pick List", ]: @@ -569,6 +570,9 @@ class SerialandBatchBundle(Document): @property def child_table(self): + if self.voucher_type == "Job Card": + return + parent_child_map = { "Asset Capitalization": "Asset Capitalization Stock Item", "Asset Repair": "Asset Repair Consumed Item", @@ -576,11 +580,11 @@ class SerialandBatchBundle(Document): "Stock Entry": "Stock Entry Detail", } - table = f"{self.voucher_type} Item" - if self.voucher_type in parent_child_map: - table = parent_child_map[self.voucher_type] - - return table + return ( + parent_child_map[self.voucher_type] + if self.voucher_type in parent_child_map + else f"{self.voucher_type} Item" + ) def delink_refernce_from_voucher(self): or_filters = {"serial_and_batch_bundle": self.name} From 5c805db57318a9d74cdf991115546aae0e310400 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 12 Jun 2023 13:06:13 +0530 Subject: [PATCH 06/11] fix(ux): add `is_cancelled=0` filter for SBB --- erpnext/public/js/controllers/transaction.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index a47d131866..953a8936b0 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -130,6 +130,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe 'item_code': item_row.item_code, 'voucher_type': doc.doctype, 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, } } }); From 7549a5c371c318395a6375696e48155245d4c659 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Wed, 14 Jun 2023 14:58:01 +0530 Subject: [PATCH 07/11] fix(ux): add filters for SBB --- .../asset_capitalization.js | 12 ++++++++++++ .../assets/doctype/asset_repair/asset_repair.js | 12 ++++++++++++ .../manufacturing/doctype/job_card/job_card.js | 11 +++++++++++ .../installation_note/installation_note.js | 11 +++++++++++ erpnext/selling/doctype/quotation/quotation.js | 12 ++++++++++++ erpnext/stock/doctype/pick_list/pick_list.js | 17 +++++++++++++++++ .../stock/doctype/stock_entry/stock_entry.js | 12 ++++++++++++ .../stock_reconciliation.js | 12 ++++++++++++ .../subcontracting_receipt.js | 12 ++++++++++++ 9 files changed, 111 insertions(+) diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js index 5a3768585a..96f4438ef7 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js @@ -65,6 +65,18 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s }; }); + me.frm.set_query("serial_and_batch_bundle", "stock_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + me.frm.set_query("item_code", "stock_items", function() { return erpnext.queries.item({"is_stock_item": 1}); }); diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js index f9ed2cc344..b2ab82cbfb 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.js +++ b/erpnext/assets/doctype/asset_repair/asset_repair.js @@ -28,6 +28,18 @@ frappe.ui.form.on('Asset Repair', { } }; }; + + frm.set_query("serial_and_batch_bundle", "stock_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, refresh: function(frm) { diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js index 5305db318b..6c9338f249 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.js +++ b/erpnext/manufacturing/doctype/job_card/job_card.js @@ -12,6 +12,17 @@ frappe.ui.form.on('Job Card', { }; }); + frm.set_query("serial_and_batch_bundle", () => { + return { + filters: { + 'item_code': frm.doc.production_item, + 'voucher_type': frm.doc.doctype, + 'voucher_no': ["in", [frm.doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + frm.set_indicator_formatter('sub_operation', function(doc) { if (doc.status == "Pending") { diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index 27a3b35ccf..d63060e6e4 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -7,6 +7,17 @@ frappe.ui.form.on('Installation Note', { frm.set_query('customer_address', erpnext.queries.address_query); frm.set_query('contact_person', erpnext.queries.contact_query); frm.set_query('customer', erpnext.queries.customer); + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, onload: function(frm) { if(!frm.doc.status) { diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 2d5c3fa961..280485a833 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -34,6 +34,18 @@ frappe.ui.form.on('Quotation', { } }; }); + + frm.set_query("serial_and_batch_bundle", "packed_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, refresh: function(frm) { diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js index 54e263130e..acbb62d0a0 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list.js @@ -12,6 +12,7 @@ frappe.ui.form.on('Pick List', { 'Delivery Note': 'Delivery Note', 'Stock Entry': 'Stock Entry', }; + frm.set_query('parent_warehouse', () => { return { filters: { @@ -20,6 +21,7 @@ frappe.ui.form.on('Pick List', { } }; }); + frm.set_query('work_order', () => { return { query: 'erpnext.stock.doctype.pick_list.pick_list.get_pending_work_orders', @@ -28,6 +30,7 @@ frappe.ui.form.on('Pick List', { } }; }); + frm.set_query('material_request', () => { return { filters: { @@ -35,9 +38,11 @@ frappe.ui.form.on('Pick List', { } }; }); + frm.set_query('item_code', 'locations', () => { return erpnext.queries.item({ "is_stock_item": 1 }); }); + frm.set_query('batch_no', 'locations', (frm, cdt, cdn) => { const row = locals[cdt][cdn]; return { @@ -48,6 +53,18 @@ frappe.ui.form.on('Pick List', { }, }; }); + + frm.set_query("serial_and_batch_bundle", "locations", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, set_item_locations:(frm, save) => { if (!(frm.doc.locations && frm.doc.locations.length)) { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 2c8e7a7da4..f1aae0edeb 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -103,6 +103,18 @@ frappe.ui.form.on('Stock Entry', { } }); + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + frm.add_fetch("bom_no", "inspection_required", "inspection_required"); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index d584858cd9..56cc21cb2c 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -30,6 +30,18 @@ frappe.ui.form.on("Stock Reconciliation", { }; }); + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + if (frm.doc.company) { erpnext.queries.setup_queries(frm, "Warehouse", function() { return erpnext.queries.warehouse(frm.doc); diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index 78572a66bc..bd1512b1e3 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -77,6 +77,18 @@ frappe.ui.form.on('Subcontracting Receipt', { } }); + frm.set_query("serial_and_batch_bundle", "supplied_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.rm_item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + let batch_no_field = frm.get_docfield('items', 'batch_no'); if (batch_no_field) { batch_no_field.get_route_options_for_new_doc = function(row) { From afaa85fbde07c1041166625ee5da493502998ff6 Mon Sep 17 00:00:00 2001 From: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:54:27 +0530 Subject: [PATCH 08/11] fix(telephony): Check if setup_phone method exists We are just overriding Data control. This fails if other field type like "Small Text" has option set as "Phone" --- erpnext/public/js/telephony.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/public/js/telephony.js b/erpnext/public/js/telephony.js index 1c3e314797..f4b0b18137 100644 --- a/erpnext/public/js/telephony.js +++ b/erpnext/public/js/telephony.js @@ -8,7 +8,7 @@ frappe.ui.form.ControlData = class ControlData extends frappe.ui.form.ControlDat Object.values(this.frm.fields_dict).forEach(function(field) { if (field.df.read_only === 1 && field.df.options === 'Phone' && field.disp_area.style[0] != 'display' && !field.has_icon) { - field.setup_phone(); + field.setup_phone && field.setup_phone(); field.has_icon = true; } }); From cd538e138a755f6df013390afb3d8268dcf97157 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 14 Jun 2023 20:28:28 +0530 Subject: [PATCH 09/11] fix: reference error while using exchange rate revaluation --- .../exchange_rate_revaluation/exchange_rate_revaluation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js index 733a7616b2..f51b90d8f6 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js @@ -36,7 +36,7 @@ frappe.ui.form.on('Exchange Rate Revaluation', { }, validate_rounding_loss: function(frm) { - allowance = frm.doc.rounding_loss_allowance; + let allowance = frm.doc.rounding_loss_allowance; if (!(allowance > 0 && allowance < 1)) { frappe.throw(__("Rounding Loss Allowance should be between 0 and 1")); } From f8273f7db66ad1ba073474ddfdd7968ba6a08e9f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 15 Jun 2023 11:37:59 +0530 Subject: [PATCH 10/11] fix: typeerror on exchange rate revaluation --- .../exchange_rate_revaluation/exchange_rate_revaluation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py index 043fbdd5d6..5d239c91f7 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py @@ -186,7 +186,7 @@ class ExchangeRateRevaluation(Document): # round off balance based on currency precision # and consider debit-credit difference allowance currency_precision = get_currency_precision() - rounding_loss_allowance = rounding_loss_allowance or 0.05 + rounding_loss_allowance = float(rounding_loss_allowance) or 0.05 for acc in account_details: acc.balance_in_account_currency = flt(acc.balance_in_account_currency, currency_precision) if abs(acc.balance_in_account_currency) <= rounding_loss_allowance: @@ -552,7 +552,7 @@ def calculate_exchange_rate_using_last_gle(company, account, party_type, party): @frappe.whitelist() def get_account_details( - company, posting_date, account, party_type=None, party=None, rounding_loss_allowance=None + company, posting_date, account, party_type=None, party=None, rounding_loss_allowance: float = None ): if not (company and posting_date): frappe.throw(_("Company and Posting Date is mandatory")) From 6a1b0a2fab64b4192063a529bfef33e97aeea47e Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Thu, 15 Jun 2023 11:39:22 +0530 Subject: [PATCH 11/11] fix: update `Stock Reconciliation` diff qty while reposting --- erpnext/stock/stock_ledger.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index a668ab89dd..b3ed220680 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -962,6 +962,7 @@ class update_entries_after(object): item.current_amount = flt(item.current_qty) * flt(item.current_valuation_rate) item.amount = flt(item.qty) * flt(item.valuation_rate) + item.quantity_difference = item.qty - item.current_qty item.amount_difference = item.amount - item.current_amount else: sr.difference_amount = sum([item.amount_difference for item in sr.items])