feat: button to get Scrap Items
This commit is contained in:
parent
7a6db924d5
commit
9b47617117
@ -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', {
|
||||
|
@ -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",
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user