From 9b47617117988a73a5f9c3bc36693d14809e896f Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 25 Aug 2023 10:53:13 +0530 Subject: [PATCH] feat: button to get Scrap Items --- .../subcontracting_receipt/subcontracting_receipt.js | 4 ++++ .../subcontracting_receipt/subcontracting_receipt.json | 9 ++++++++- .../subcontracting_receipt/subcontracting_receipt.py | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index 94a2589b98..3824853255 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -204,6 +204,10 @@ frappe.ui.form.on('Subcontracting Receipt Item', { rate(frm) { set_missing_values(frm); }, + + items_remove: function(frm) { + set_missing_values(frm); + } }); frappe.ui.form.on('Subcontracting Receipt Supplied Item', { diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json index 4b3cc8365c..95fe087d9a 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json @@ -40,6 +40,7 @@ "col_break_warehouse", "supplier_warehouse", "items_section", + "get_scrap_items", "items", "section_break0", "total_qty", @@ -626,12 +627,18 @@ "fieldtype": "Check", "label": "Edit Posting Date and Time", "print_hide": 1 + }, + { + "fieldname": "get_scrap_items", + "fieldtype": "Button", + "label": "Get Scrap Items", + "options": "get_scrap_items" } ], "in_create": 1, "is_submittable": 1, "links": [], - "modified": "2023-07-06 18:43:16.171842", + "modified": "2023-08-25 10:02:11.546559", "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Receipt", diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index 36be4d1035..5f64ab1323 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -147,6 +147,7 @@ class SubcontractingReceipt(SubcontractingController): ): self.supplied_items = [] + @frappe.whitelist() def get_scrap_items(self): if ( frappe.db.get_single_value("Buying Settings", "backflush_raw_materials_of_subcontract_based_on") @@ -176,11 +177,16 @@ class SubcontractingReceipt(SubcontractingController): "recalculate_rate": 0, }, ) + else: + self.calculate_additional_costs() + self.calculate_items_qty_and_amount() def remove_scrap_items(self): for item in list(self.items): if item.is_scrap_item: self.remove(item) + else: + item.scrap_cost_per_qty = 0 @frappe.whitelist() def set_missing_values(self): @@ -239,6 +245,8 @@ class SubcontractingReceipt(SubcontractingController): scrap_cost_map[item.reference_name] += item.amount else: scrap_cost_map[item.reference_name] = item.amount + else: + item.scrap_cost_per_qty = 0 total_qty = total_amount = 0 for item in self.items: