Added BOM UOM selection for items

Added patch for BOM Item UOM

Fixed scrap qty issue

Added Scrap Qty update to patch

Reverted test record for production order
This commit is contained in:
Ben Cornwell-Mott 2017-05-23 15:15:17 -07:00
parent 3b9c2a4438
commit 0f0b121669
12 changed files with 325 additions and 103 deletions

View File

@ -252,7 +252,7 @@ class BuyingController(StockController):
def get_items_from_bom(self, item_code, bom): def get_items_from_bom(self, item_code, bom):
bom_items = frappe.db.sql("""select t2.item_code, bom_items = frappe.db.sql("""select t2.item_code,
t2.qty / ifnull(t1.quantity, 1) as qty_consumed_per_unit, t2.stock_qty / ifnull(t1.quantity, 1) as qty_consumed_per_unit,
t2.rate, t2.stock_uom, t2.name, t2.description t2.rate, t2.stock_uom, t2.name, t2.description
from `tabBOM` t1, `tabBOM Item` t2, tabItem t3 from `tabBOM` t1, `tabBOM Item` t2, tabItem t3
where t2.parent = t1.name and t1.item = %s where t2.parent = t1.name and t1.item = %s

View File

@ -70,6 +70,15 @@ erpnext.bom.BomController = erpnext.TransactionController.extend({
get_bom_material_detail(doc, cdt, cdn, scrap_items); get_bom_material_detail(doc, cdt, cdn, scrap_items);
}, },
conversion_factor: function(doc, cdt, cdn, dont_fetch_price_list_rate) {
if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["qty", "conversion_factor"]);
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
refresh_field("stock_qty", item.name, item.parentfield);
this.toggle_conversion_factor(item);
}
},
}) })
$.extend(cur_frm.cscript, new erpnext.bom.BomController({frm: cur_frm})); $.extend(cur_frm.cscript, new erpnext.bom.BomController({frm: cur_frm}));
@ -296,6 +305,14 @@ frappe.ui.form.on("BOM Operation", "workstation", function(frm, cdt, cdn) {
}) })
}); });
frappe.ui.form.on("BOM Item", "qty", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
d.stock_qty = d.qty * d.conversion_factor
refresh_field("items");
});
frappe.ui.form.on("BOM Operation", "operations_remove", function(frm) { frappe.ui.form.on("BOM Operation", "operations_remove", function(frm) {
erpnext.bom.calculate_op_cost(frm.doc); erpnext.bom.calculate_op_cost(frm.doc);
erpnext.bom.calculate_total(frm.doc); erpnext.bom.calculate_total(frm.doc);

View File

@ -7,6 +7,7 @@ from frappe.utils import cint, cstr, flt
from frappe import _ from frappe import _
from erpnext.setup.utils import get_exchange_rate from erpnext.setup.utils import get_exchange_rate
from frappe.website.website_generator import WebsiteGenerator from frappe.website.website_generator import WebsiteGenerator
from erpnext.stock.get_item_details import get_conversion_factor
from operator import itemgetter from operator import itemgetter
@ -48,7 +49,7 @@ class BOM(WebsiteGenerator):
self.set_conversion_rate() self.set_conversion_rate()
from erpnext.utilities.transaction_base import validate_uom_is_integer from erpnext.utilities.transaction_base import validate_uom_is_integer
validate_uom_is_integer(self, "stock_uom", "qty", "BOM Item") validate_uom_is_integer(self, "stock_uom", "stock_qty", "BOM Item")
self.validate_materials() self.validate_materials()
self.set_bom_material_details() self.set_bom_material_details()
@ -60,6 +61,7 @@ class BOM(WebsiteGenerator):
def on_update(self): def on_update(self):
self.check_recursion() self.check_recursion()
self.update_stock_qty()
self.update_exploded_items() self.update_exploded_items()
def on_submit(self): def on_submit(self):
@ -94,7 +96,7 @@ class BOM(WebsiteGenerator):
def set_bom_material_details(self): def set_bom_material_details(self):
for item in self.get("items"): for item in self.get("items"):
ret = self.get_bom_material_detail({"item_code": item.item_code, "item_name": item.item_name, "bom_no": item.bom_no, ret = self.get_bom_material_detail({"item_code": item.item_code, "item_name": item.item_name, "bom_no": item.bom_no,
"qty": item.qty}) "stock_qty": item.stock_qty})
for r in ret: for r in ret:
if not item.get(r): if not item.get(r):
item.set(r, ret[r]) item.set(r, ret[r])
@ -122,6 +124,8 @@ class BOM(WebsiteGenerator):
'description' : item and args['description'] or '', 'description' : item and args['description'] or '',
'image' : item and args['image'] or '', 'image' : item and args['image'] or '',
'stock_uom' : item and args['stock_uom'] or '', 'stock_uom' : item and args['stock_uom'] or '',
'uom' : item and args['stock_uom'] or '',
'conversion_factor' : 1,
'bom_no' : args['bom_no'], 'bom_no' : args['bom_no'],
'rate' : rate, 'rate' : rate,
'base_rate' : rate if self.company_currency() == self.currency else rate * self.conversion_rate 'base_rate' : rate if self.company_currency() == self.currency else rate * self.conversion_rate
@ -159,7 +163,7 @@ class BOM(WebsiteGenerator):
for d in self.get("items"): for d in self.get("items"):
rate = self.get_bom_material_detail({'item_code': d.item_code, 'bom_no': d.bom_no, rate = self.get_bom_material_detail({'item_code': d.item_code, 'bom_no': d.bom_no,
'qty': d.qty})["rate"] 'stock_qty': d.stock_qty})["rate"]
if rate: if rate:
d.rate = rate d.rate = rate
@ -239,6 +243,19 @@ class BOM(WebsiteGenerator):
frappe.db.get_value('Price List', self.buying_price_list, 'currency') != self.currency: frappe.db.get_value('Price List', self.buying_price_list, 'currency') != self.currency:
frappe.throw(_("Currency of the price list {0} is not similar with the selected currency {1}").format(self.buying_price_list, self.currency)) frappe.throw(_("Currency of the price list {0} is not similar with the selected currency {1}").format(self.buying_price_list, self.currency))
def update_stock_qty(self):
for m in self.get('items'):
if not m.conversion_factor:
m.conversion_factor = flt(get_conversion_factor(m.item_code, m.uom)['conversion_factor'])
if m.uom and m.qty:
m.stock_qty = flt(m.conversion_factor)*flt(m.qty)
if not m.uom and m.stock_uom:
m.uom = m.stock_uom
m.qty = m.stock_qty
def set_conversion_rate(self): def set_conversion_rate(self):
self.conversion_rate = get_exchange_rate(self.currency, self.company_currency()) self.conversion_rate = get_exchange_rate(self.currency, self.company_currency())
@ -250,7 +267,7 @@ class BOM(WebsiteGenerator):
for m in self.get('items'): for m in self.get('items'):
if m.bom_no: if m.bom_no:
validate_bom_no(m.item_code, m.bom_no) validate_bom_no(m.item_code, m.bom_no)
if flt(m.qty) <= 0: if flt(m.stock_qty) <= 0:
frappe.throw(_("Quantity required for Item {0} in row {1}").format(m.item_code, m.idx)) frappe.throw(_("Quantity required for Item {0} in row {1}").format(m.item_code, m.idx))
check_list.append(cstr(m.item_code)) check_list.append(cstr(m.item_code))
unique_chk_list = set(check_list) unique_chk_list = set(check_list)
@ -336,9 +353,9 @@ class BOM(WebsiteGenerator):
d.rate = self.get_bom_unitcost(d.bom_no) d.rate = self.get_bom_unitcost(d.bom_no)
d.base_rate = flt(d.rate) * flt(self.conversion_rate) d.base_rate = flt(d.rate) * flt(self.conversion_rate)
d.amount = flt(d.rate, self.precision("rate", d)) * flt(d.qty, self.precision("qty", d)) d.amount = flt(d.rate, self.precision("rate", d)) * flt(d.stock_qty, self.precision("stock_qty", d))
d.base_amount = d.amount * flt(self.conversion_rate) d.base_amount = d.amount * flt(self.conversion_rate)
d.qty_consumed_per_unit = flt(d.qty, self.precision("qty", d)) / flt(self.quantity, self.precision("quantity")) d.qty_consumed_per_unit = flt(d.stock_qty, self.precision("stock_qty", d)) / flt(self.quantity, self.precision("quantity"))
total_rm_cost += d.amount total_rm_cost += d.amount
base_total_rm_cost += d.base_amount base_total_rm_cost += d.base_amount
@ -352,7 +369,7 @@ class BOM(WebsiteGenerator):
for d in self.get('scrap_items'): for d in self.get('scrap_items'):
d.base_rate = d.rate * self.conversion_rate d.base_rate = d.rate * self.conversion_rate
d.amount = flt(d.rate, self.precision("rate", d)) * flt(d.qty, self.precision("qty", d)) d.amount = flt(d.rate, self.precision("rate", d)) * flt(d.stock_qty, self.precision("stock_qty", d))
d.base_amount = d.amount * self.conversion_rate d.base_amount = d.amount * self.conversion_rate
total_sm_cost += d.amount total_sm_cost += d.amount
base_total_sm_cost += d.base_amount base_total_sm_cost += d.base_amount
@ -370,7 +387,7 @@ class BOM(WebsiteGenerator):
self.cur_exploded_items = {} self.cur_exploded_items = {}
for d in self.get('items'): for d in self.get('items'):
if d.bom_no: if d.bom_no:
self.get_child_exploded_items(d.bom_no, d.qty) self.get_child_exploded_items(d.bom_no, d.stock_qty)
else: else:
self.add_to_cur_exploded_items(frappe._dict({ self.add_to_cur_exploded_items(frappe._dict({
'item_code' : d.item_code, 'item_code' : d.item_code,
@ -378,7 +395,7 @@ class BOM(WebsiteGenerator):
'description' : d.description, 'description' : d.description,
'image' : d.image, 'image' : d.image,
'stock_uom' : d.stock_uom, 'stock_uom' : d.stock_uom,
'qty' : flt(d.qty), 'qty' : flt(d.stock_qty),
'rate' : d.base_rate, 'rate' : d.base_rate,
})) }))
@ -453,7 +470,7 @@ def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1, fetch_scrap_ite
query = """select query = """select
bom_item.item_code, bom_item.item_code,
item.item_name, item.item_name,
sum(bom_item.qty/ifnull(bom.quantity, 1)) * %(qty)s as qty, sum(bom_item.stock_qty/ifnull(bom.quantity, 1)) * %(qty)s as qty,
item.description, item.description,
item.image, item.image,
item.stock_uom, item.stock_uom,
@ -521,7 +538,7 @@ def get_children():
return frappe.db.sql("""select return frappe.db.sql("""select
bom_item.item_code, bom_item.item_code,
bom_item.bom_no as value, bom_item.bom_no as value,
bom_item.qty, bom_item.stock_qty,
if(ifnull(bom_item.bom_no, "")!="", 1, 0) as expandable, if(ifnull(bom_item.bom_no, "")!="", 1, 0) as expandable,
item.image, item.image,
item.description item.description

View File

@ -6,7 +6,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Serialized Item With Series", "item_code": "_Test Serialized Item With Series",
"parentfield": "items", "parentfield": "items",
"qty": 1.0, "stock_qty": 1.0,
"rate": 5000.0, "rate": 5000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
}, },
@ -15,7 +15,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item 2", "item_code": "_Test Item 2",
"parentfield": "items", "parentfield": "items",
"qty": 2.0, "stock_qty": 2.0,
"rate": 1000.0, "rate": 1000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
} }
@ -35,7 +35,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item Home Desktop 100", "item_code": "_Test Item Home Desktop 100",
"parentfield": "items", "parentfield": "items",
"qty": 1.0, "stock_qty": 1.0,
"rate": 2000.0, "rate": 2000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
} }
@ -46,7 +46,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item", "item_code": "_Test Item",
"parentfield": "items", "parentfield": "items",
"qty": 1.0, "stock_qty": 1.0,
"rate": 5000.0, "rate": 5000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
}, },
@ -55,7 +55,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item Home Desktop 100", "item_code": "_Test Item Home Desktop 100",
"parentfield": "items", "parentfield": "items",
"qty": 2.0, "stock_qty": 2.0,
"rate": 1000.0, "rate": 1000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
} }
@ -84,7 +84,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item", "item_code": "_Test Item",
"parentfield": "items", "parentfield": "items",
"qty": 1.0, "stock_qty": 1.0,
"rate": 5000.0, "rate": 5000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
}, },
@ -94,7 +94,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item Home Desktop Manufactured", "item_code": "_Test Item Home Desktop Manufactured",
"parentfield": "items", "parentfield": "items",
"qty": 3.0, "stock_qty": 3.0,
"rate": 1000.0, "rate": 1000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
} }
@ -124,7 +124,7 @@
"doctype": "BOM Item", "doctype": "BOM Item",
"item_code": "_Test Item", "item_code": "_Test Item",
"parentfield": "items", "parentfield": "items",
"qty": 2.0, "stock_qty": 2.0,
"rate": 3000.0, "rate": 3000.0,
"stock_uom": "_Test UOM" "stock_uom": "_Test UOM"
} }

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"beta": 0, "beta": 0,
@ -11,6 +12,7 @@
"editable_grid": 1, "editable_grid": 1,
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -20,7 +22,8 @@
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Item Code", "label": "Item Code",
@ -41,6 +44,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -51,6 +55,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Item Name", "label": "Item Name",
@ -69,6 +74,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -79,6 +85,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"length": 0, "length": 0,
@ -96,6 +103,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -105,7 +113,8 @@
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 1, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "BOM No", "label": "BOM No",
@ -128,6 +137,7 @@
"width": "150px" "width": "150px"
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -138,6 +148,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"length": 0, "length": 0,
@ -155,6 +166,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -165,6 +177,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Item Description", "label": "Item Description",
@ -186,6 +199,7 @@
"width": "250px" "width": "250px"
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -196,6 +210,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"length": 0, "length": 0,
@ -212,6 +227,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -222,6 +238,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Image", "label": "Image",
@ -240,6 +257,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -250,6 +268,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Image View", "label": "Image View",
@ -269,6 +288,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -279,6 +299,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Quantity and Rate", "label": "Quantity and Rate",
@ -296,6 +317,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -306,6 +328,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Qty", "label": "Qty",
@ -319,16 +342,168 @@
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 1,
"fieldname": "uom",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "UOM",
"length": 0,
"no_copy": 0,
"options": "UOM",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "col_break2",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "stock_qty",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Stock Qty",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 2, "columns": 0,
"fieldname": "conversion_factor",
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Conversion Factor",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "stock_uom",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Stock UOM",
"length": 0,
"no_copy": 0,
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "See \"Rate Of Materials Based On\" in Costing Section", "description": "See \"Rate Of Materials Based On\" in Costing Section",
"fieldname": "rate", "fieldname": "rate",
"fieldtype": "Currency", "fieldtype": "Currency",
@ -336,7 +511,8 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_list_view": 1, "in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Rate", "label": "Rate",
"length": 0, "length": 0,
@ -354,6 +530,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -364,6 +541,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Amount", "label": "Amount",
@ -386,62 +564,7 @@
"width": "150px" "width": "150px"
}, },
{ {
"allow_on_submit": 0, "allow_bulk_edit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "col_break2",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "stock_uom",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Stock UOM",
"length": 0,
"no_copy": 0,
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -452,6 +575,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Basic Rate (Company Currency)", "label": "Basic Rate (Company Currency)",
@ -471,6 +595,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -481,6 +606,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Amount (Company Currency)", "label": "Amount (Company Currency)",
@ -500,6 +626,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -510,6 +637,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"length": 0, "length": 0,
@ -527,6 +655,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -537,6 +666,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Scrap %", "label": "Scrap %",
@ -556,6 +686,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -566,6 +697,7 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Qty Consumed Per Unit", "label": "Qty Consumed Per Unit",
@ -585,18 +717,18 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"idx": 1, "idx": 1,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-12-20 12:54:34.859076", "modified": "2017-05-23 15:59:37.946963",
"modified_by": "rmehta@gmail.com", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "BOM Item", "name": "BOM Item",
"owner": "Administrator", "owner": "Administrator",
@ -604,7 +736,9 @@
"quick_entry": 0, "quick_entry": 0,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"track_changes": 0,
"track_seen": 0 "track_seen": 0
} }

View File

@ -33,7 +33,7 @@ class BOMReplaceTool(Document):
from `tabBOM` where name = %s""", self.current_bom) from `tabBOM` where name = %s""", self.current_bom)
current_bom_unitcost = current_bom_unitcost and flt(current_bom_unitcost[0][0]) or 0 current_bom_unitcost = current_bom_unitcost and flt(current_bom_unitcost[0][0]) or 0
frappe.db.sql("""update `tabBOM Item` set bom_no=%s, frappe.db.sql("""update `tabBOM Item` set bom_no=%s,
rate=%s, amount=qty*%s where bom_no = %s and docstatus < 2""", rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2""",
(self.new_bom, current_bom_unitcost, current_bom_unitcost, self.current_bom)) (self.new_bom, current_bom_unitcost, current_bom_unitcost, self.current_bom))
def get_parent_boms(self): def get_parent_boms(self):

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"beta": 0, "beta": 0,
@ -11,6 +12,7 @@
"editable_grid": 1, "editable_grid": 1,
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -21,7 +23,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Item Code", "label": "Item Code",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -31,6 +35,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
@ -38,6 +43,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -48,7 +54,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Item Name", "label": "Item Name",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -57,6 +65,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -64,6 +73,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -74,7 +84,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Quantity and Rate", "label": "Quantity and Rate",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -83,6 +95,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -90,17 +103,20 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "qty", "fieldname": "stock_qty",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Qty", "label": "Qty",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -109,6 +125,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
@ -116,6 +133,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -126,7 +144,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Rate", "label": "Rate",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -136,6 +156,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -143,6 +164,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -153,7 +175,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Amount", "label": "Amount",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -163,6 +187,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -170,6 +195,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -180,7 +206,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -188,6 +216,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -195,6 +224,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -205,7 +235,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Stock UOM", "label": "Stock UOM",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -215,6 +247,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -222,6 +255,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -232,7 +266,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Basic Rate (Company Currency)", "label": "Basic Rate (Company Currency)",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -242,6 +278,7 @@
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -249,6 +286,7 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -259,7 +297,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Basic Amount (Company Currency)", "label": "Basic Amount (Company Currency)",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -269,6 +309,7 @@
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -276,17 +317,17 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"idx": 0, "idx": 0,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-10-25 00:27:53.712140", "modified": "2017-05-23 16:04:32.442287",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "BOM Scrap Item", "name": "BOM Scrap Item",
@ -296,7 +337,9 @@
"quick_entry": 1, "quick_entry": 1,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"track_changes": 1,
"track_seen": 0 "track_seen": 0
} }

View File

@ -348,7 +348,7 @@ class ProductionPlanningTool(Document):
SELECT SELECT
bom_item.item_code, bom_item.item_code,
default_material_request_type, default_material_request_type,
ifnull(%(parent_qty)s * sum(bom_item.qty/ifnull(bom.quantity, 1)), 0) as qty, ifnull(%(parent_qty)s * sum(bom_item.stock_qty/ifnull(bom.quantity, 1)), 0) as qty,
item.is_sub_contracted_item as is_sub_contracted, item.is_sub_contracted_item as is_sub_contracted,
item.default_bom as default_bom, item.default_bom as default_bom,
bom_item.description as description, bom_item.description as description,

View File

@ -235,9 +235,9 @@ def create_test_records():
"is_active": 1, "is_active": 1,
"is_default": 1, "is_default": 1,
"docstatus": 1, "docstatus": 1,
"with_operations": 0}, [{"item_code": "_Test PPT Item Raw B", "doctype":"BOM Item", "qty":1, "with_operations": 0}, [{"item_code": "_Test PPT Item Raw B", "doctype":"BOM Item", "stock_qty":1,
"rate":100, "amount": 100, "stock_uom": "_Test UOM"}, "rate":100, "amount": 100, "stock_uom": "_Test UOM"},
{"item_code": "_Test PPT Item Raw C", "doctype":"BOM Item", "qty":4, "rate":100, {"item_code": "_Test PPT Item Raw C", "doctype":"BOM Item", "stock_qty":4, "rate":100,
"amount": 400,"stock_uom": "_Test UOM"}]) "amount": 400,"stock_uom": "_Test UOM"}])
bom_subC = make_bom("BOM-_Test PPT Item Sub C-001",{"quantity":1, bom_subC = make_bom("BOM-_Test PPT Item Sub C-001",{"quantity":1,
@ -247,9 +247,9 @@ def create_test_records():
"docstatus": 1, "docstatus": 1,
"with_operations": 0}, [ "with_operations": 0}, [
{"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A", {"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A",
"doctype":"BOM Item", "qty":6, "rate":100, "amount": 600}, "doctype":"BOM Item", "stock_qty":6, "rate":100, "amount": 600},
{"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B", {"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B",
"bom_no":"BOM-_Test PPT Item Sub B-001", "doctype":"BOM Item", "qty":2, "bom_no":"BOM-_Test PPT Item Sub B-001", "doctype":"BOM Item", "stock_qty":2,
"rate":100, "amount": 200}]) "rate":100, "amount": 200}])
bom_sCA = make_bom("BOM-_Test PPT Item SC A-001",{"quantity":1, bom_sCA = make_bom("BOM-_Test PPT Item SC A-001",{"quantity":1,
@ -259,7 +259,7 @@ def create_test_records():
"docstatus": 1, "docstatus": 1,
"with_operations": 0}, [ "with_operations": 0}, [
{"item_code": "_Test PPT Item Raw D","item_name": "_Test PPT Item Raw D", {"item_code": "_Test PPT Item Raw D","item_name": "_Test PPT Item Raw D",
"doctype":"BOM Item", "qty":1, "rate":100, "amount": 100}]) "doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100}])
bom_sCB = make_bom("BOM-_Test PPT Item SC B-001",{"quantity":1, bom_sCB = make_bom("BOM-_Test PPT Item SC B-001",{"quantity":1,
"item": "_Test PPT Item SC B", "item": "_Test PPT Item SC B",
@ -268,9 +268,9 @@ def create_test_records():
"docstatus": 1, "docstatus": 1,
"with_operations": 0}, [ "with_operations": 0}, [
{"item_code": "_Test PPT Item Raw B","item_name": "_Test PPT Item Raw B", {"item_code": "_Test PPT Item Raw B","item_name": "_Test PPT Item Raw B",
"doctype":"BOM Item", "qty":1, "rate":100, "amount": 100}, "doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100},
{"item_code": "_Test PPT Item Raw C","item_name": "_Test PPT Item Raw C", {"item_code": "_Test PPT Item Raw C","item_name": "_Test PPT Item Raw C",
"doctype":"BOM Item", "qty":4, "rate":100, "amount": 400}]) "doctype":"BOM Item", "stock_qty":4, "rate":100, "amount": 400}])
bom_subA = make_bom("BOM-_Test PPT Item Sub A-001",{"quantity":1, bom_subA = make_bom("BOM-_Test PPT Item Sub A-001",{"quantity":1,
"item": "_Test PPT Item Sub A", "item": "_Test PPT Item Sub A",
@ -280,9 +280,9 @@ def create_test_records():
"with_operations": 0}, [ "with_operations": 0}, [
{"item_code": "_Test PPT Item Sub C","item_name": "_Test PPT Item Sub C", {"item_code": "_Test PPT Item Sub C","item_name": "_Test PPT Item Sub C",
"bom_no":"BOM-_Test PPT Item Sub C-001", "doctype":"BOM Item", "bom_no":"BOM-_Test PPT Item Sub C-001", "doctype":"BOM Item",
"qty":1, "rate":100, "amount": 100}, "stock_qty":1, "rate":100, "amount": 100},
{"item_code": "_Test PPT Item SC B","item_name": "_Test PPT Item SC B", {"item_code": "_Test PPT Item SC B","item_name": "_Test PPT Item SC B",
"bom_no":"BOM-_Test PPT Item SC B-001", "doctype":"BOM Item", "qty":2, "bom_no":"BOM-_Test PPT Item SC B-001", "doctype":"BOM Item", "stock_qty":2,
"rate":100, "amount": 200}]) "rate":100, "amount": 200}])
bom_master = make_bom("BOM-_Test PPT Item Master-001",{"quantity":1, bom_master = make_bom("BOM-_Test PPT Item Master-001",{"quantity":1,
@ -293,16 +293,16 @@ def create_test_records():
"with_operations": 0}, [ "with_operations": 0}, [
{"item_code": "_Test PPT Item Sub A","item_name": "_Test PPT Item Sub A", {"item_code": "_Test PPT Item Sub A","item_name": "_Test PPT Item Sub A",
"bom_no":"BOM-_Test PPT Item Sub A-001", "bom_no":"BOM-_Test PPT Item Sub A-001",
"doctype":"BOM Item", "qty":2, "rate":100, "amount": 200}, "doctype":"BOM Item", "stock_qty":2, "rate":100, "amount": 200},
{"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B", {"item_code": "_Test PPT Item Sub B","item_name": "_Test PPT Item Sub B",
"bom_no":"BOM-_Test PPT Item Sub B-001", "bom_no":"BOM-_Test PPT Item Sub B-001",
"doctype":"BOM Item", "qty":1, "rate":100, "amount": 100}, "doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100},
{"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A", {"item_code": "_Test PPT Item Raw A","item_name": "_Test PPT Item Raw A",
"doctype":"BOM Item", "qty":2, "rate":100, "doctype":"BOM Item", "stock_qty":2, "rate":100,
"amount": 200}, "amount": 200},
{"item_code": "_Test PPT Item SC A","item_name": "_Test PPT Item SC A", {"item_code": "_Test PPT Item SC A","item_name": "_Test PPT Item SC A",
"bom_no":"BOM-_Test PPT Item SC A-001", "bom_no":"BOM-_Test PPT Item SC A-001",
"doctype":"BOM Item", "qty":1, "rate":100, "amount": 100} "doctype":"BOM Item", "stock_qty":1, "rate":100, "amount": 100}
]) ])

View File

@ -23,7 +23,7 @@ def get_item_list(prod_list, filters):
item_list = frappe.db.sql("""SELECT item_list = frappe.db.sql("""SELECT
bom_item.item_code as item_code, bom_item.item_code as item_code,
ifnull(ledger.actual_qty*bom.quantity/bom_item.qty,0) as build_qty ifnull(ledger.actual_qty*bom.quantity/bom_item.stock_qty,0) as build_qty
FROM FROM
`tabBOM` as bom, `tabBOM Item` AS bom_item `tabBOM` as bom, `tabBOM Item` AS bom_item
LEFT JOIN `tabBin` AS ledger LEFT JOIN `tabBin` AS ledger

View File

@ -396,4 +396,5 @@ erpnext.patches.v8_0.merge_student_batch_and_student_group
erpnext.patches.v8_0.rename_total_margin_to_rate_with_margin # 11-05-2017 erpnext.patches.v8_0.rename_total_margin_to_rate_with_margin # 11-05-2017
erpnext.patches.v8_0.fix_status_for_invoices_with_negative_outstanding erpnext.patches.v8_0.fix_status_for_invoices_with_negative_outstanding
erpnext.patches.v8_0.make_payments_table_blank_for_non_pos_invoice erpnext.patches.v8_0.make_payments_table_blank_for_non_pos_invoice
erpnext.patches.v8_0.set_sales_invoice_serial_number_from_delivery_note erpnext.patches.v8_0.set_sales_invoice_serial_number_from_delivery_note
erpnext.patches.v8_0.update_stock_qty_value_in_bom_item

View File

@ -0,0 +1,10 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('manufacturing', 'doctype', 'bom_item')
frappe.db.sql("update `tabBOM Item` set stock_qty = qty, uom = stock_uom")
frappe.db.sql("update `tabBOM Scrap Item` set stock_qty = qty")