Skip to content

Commit 5333015

Browse files
author
tobaman
committed
bug fix custom BOM
1 parent 34d5393 commit 5333015

File tree

2 files changed

+52
-9
lines changed

2 files changed

+52
-9
lines changed

tcs_bugfix/hooks.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
# include js, css files in header of desk.html
2828
# app_include_css = "/assets/tcs_bugfix/css/tcs_bugfix.css"
29-
# app_include_js = "/assets/tcs_bugfix/js/tcs_bugfix.js"
30-
29+
#app_include_js = ["tcs_bugfix.bundle.js"]
30+
3131
# include js, css files in header of web template
3232
# web_include_css = "/assets/tcs_bugfix/css/tcs_bugfix.css"
3333
# web_include_js = "/assets/tcs_bugfix/js/tcs_bugfix.js"
@@ -43,7 +43,9 @@
4343
# page_js = {"page" : "public/js/file.js"}
4444

4545
# include js in doctype views
46-
# doctype_js = {"doctype" : "public/js/doctype.js"}
46+
doctype_js = {
47+
"BOM": "public/js/custom_bom.js",
48+
}
4749
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
4850
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
4951
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
@@ -129,9 +131,9 @@
129131
# ---------------
130132
# Override standard doctype classes
131133

132-
# override_doctype_class = {
133-
# "ToDo": "custom_app.overrides.CustomToDo"
134-
# }
134+
#override_doctype_class = {
135+
# "BOM": "tcs_bugfix.overrides.bom.CustomBOM"
136+
#}
135137

136138
# Document Events
137139
# ---------------
@@ -174,9 +176,10 @@
174176
# Overriding Methods
175177
# ------------------------------
176178
#
177-
# override_whitelisted_methods = {
178-
# "frappe.desk.doctype.event.event.get_events": "tcs_bugfix.event.get_events"
179-
# }
179+
#override_whitelisted_methods = {
180+
# "erpnext.manufacturing.doctype.bom.bom.get_bom_material_detail": "tcs_bugfix.overrides.bom.get_bom_material_detail_fixed"
181+
#}
182+
#}
180183
#
181184
# each overriding function accepts a `data` argument;
182185
# generated from the base implementation of the doctype dashboard,

tcs_bugfix/public/js/custom_bom.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//untuk BOM di versi ERPNEXT Versi 15.95 dimana fixnya dari Versi 15.95.1
2+
var get_bom_material_detail = function (doc, cdt, cdn, scrap_items) {
3+
if (!doc.company) {
4+
frappe.throw({ message: __("Please select a Company first."), title: __("Mandatory") });
5+
}
6+
7+
var d = locals[cdt][cdn];
8+
if (d.item_code) {
9+
return frappe.call({
10+
doc: doc,
11+
method: "get_bom_material_detail",
12+
args: {
13+
company: doc.company,
14+
item_code: d.item_code,
15+
bom_no: d.bom_no != null ? d.bom_no : "",
16+
scrap_items: scrap_items,
17+
qty: d.qty,
18+
stock_qty: d.stock_qty,
19+
include_item_in_manufacturing: d.include_item_in_manufacturing,
20+
uom: d.uom,
21+
stock_uom: d.stock_uom,
22+
conversion_factor: d.conversion_factor,
23+
sourced_by_supplier: d.sourced_by_supplier,
24+
do_not_explode: d.do_not_explode,
25+
},
26+
callback: function (r) {
27+
28+
$.extend(d, r.message);
29+
refresh_field("items");
30+
refresh_field("scrap_items");
31+
32+
doc = locals[doc.doctype][doc.name];
33+
erpnext.bom.calculate_rm_cost(doc);
34+
erpnext.bom.calculate_scrap_materials_cost(doc);
35+
erpnext.bom.calculate_total(doc);
36+
},
37+
freeze: true,
38+
});
39+
}
40+
};

0 commit comments

Comments
 (0)