mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
feat: add is process loss autoset and validation
This commit is contained in:
@@ -360,6 +360,14 @@ frappe.ui.form.on("BOM", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function set_is_process_loss(doc, cdt, cdn) {
|
||||||
|
const row = locals[cdt][cdn]
|
||||||
|
if (row.item_code === doc.item) {
|
||||||
|
row.is_process_loss = 1
|
||||||
|
frappe.msgprint(__("Item:") + ` ${row.item_code} ` + __("set as process loss."))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
erpnext.bom.BomController = erpnext.TransactionController.extend({
|
erpnext.bom.BomController = erpnext.TransactionController.extend({
|
||||||
conversion_rate: function(doc) {
|
conversion_rate: function(doc) {
|
||||||
if(this.frm.doc.currency === this.get_company_currency()) {
|
if(this.frm.doc.currency === this.get_company_currency()) {
|
||||||
@@ -380,6 +388,9 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({
|
|||||||
child.bom_no = '';
|
child.bom_no = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scrap_items) {
|
||||||
|
set_is_process_loss(doc, cdt, cdn)
|
||||||
|
}
|
||||||
get_bom_material_detail(doc, cdt, cdn, scrap_items);
|
get_bom_material_detail(doc, cdt, cdn, scrap_items);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -447,6 +458,10 @@ var get_bom_material_detail = function(doc, cdt, cdn, scrap_items) {
|
|||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
d = locals[cdt][cdn];
|
d = locals[cdt][cdn];
|
||||||
|
if (d.is_process_loss) {
|
||||||
|
r.message.rate = 0
|
||||||
|
r.message.base_rate = 0
|
||||||
|
}
|
||||||
$.extend(d, r.message);
|
$.extend(d, r.message);
|
||||||
refresh_field("items");
|
refresh_field("items");
|
||||||
refresh_field("scrap_items");
|
refresh_field("scrap_items");
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class BOM(WebsiteGenerator):
|
|||||||
self.validate_operations()
|
self.validate_operations()
|
||||||
self.calculate_cost()
|
self.calculate_cost()
|
||||||
self.update_stock_qty()
|
self.update_stock_qty()
|
||||||
|
self.validate_scrap_items()
|
||||||
self.update_cost(update_parent=False, from_child_bom=True, save=False)
|
self.update_cost(update_parent=False, from_child_bom=True, save=False)
|
||||||
|
|
||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
@@ -585,6 +586,15 @@ class BOM(WebsiteGenerator):
|
|||||||
if not d.batch_size or d.batch_size <= 0:
|
if not d.batch_size or d.batch_size <= 0:
|
||||||
d.batch_size = 1
|
d.batch_size = 1
|
||||||
|
|
||||||
|
def validate_scrap_items(self):
|
||||||
|
for item in self.scrap_items:
|
||||||
|
if item.item_code == self.item and not item.is_process_loss:
|
||||||
|
frappe.throw(_('Item:') + f' {item.item_code} ' +\
|
||||||
|
_('in Scrap/Loss Items table should have Is Process Loss checked.'))
|
||||||
|
elif item.item_code != self.item and item.is_process_loss:
|
||||||
|
frappe.throw(_('Item:') + f' {item.item_code} ' +\
|
||||||
|
_('in Scrap/Loss Items table should not have Is Process Loss checked.'))
|
||||||
|
|
||||||
def get_bom_item_rate(args, bom_doc):
|
def get_bom_item_rate(args, bom_doc):
|
||||||
if bom_doc.rm_cost_as_per == 'Valuation Rate':
|
if bom_doc.rm_cost_as_per == 'Valuation Rate':
|
||||||
rate = get_valuation_rate(args) * (args.get("conversion_factor") or 1)
|
rate = get_valuation_rate(args) * (args.get("conversion_factor") or 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user