fix(test): BOM raw materials rate from price list as per uom

This commit is contained in:
Nabin Hait 2019-01-14 20:03:45 +05:30
parent 158e7dcd8b
commit 78ccbe24a3
2 changed files with 6 additions and 6 deletions

View File

@ -76,7 +76,7 @@ class TestBOM(unittest.TestCase):
# update cost of all BOMs based on latest valuation rate
update_cost()
# check if new valuation rate updated in all BOMs
for d in frappe.db.sql("""select rate from `tabBOM Item`
where item_code='_Test Item 2' and docstatus=1 and parenttype='BOM'""", as_dict=1):
@ -97,6 +97,7 @@ class TestBOM(unittest.TestCase):
self.assertEqual(bom.base_total_cost, 486000)
def test_bom_cost_multi_uom_multi_currency(self):
frappe.db.set_value("Price List", "_Test Price List", "price_not_uom_dependant", 1)
for item_code, rate in (("_Test Item", 3600), ("_Test Item Home Desktop Manufactured", 3000)):
frappe.db.sql("delete from `tabItem Price` where price_list='_Test Price List' and item_code=%s",
item_code)
@ -105,7 +106,7 @@ class TestBOM(unittest.TestCase):
item_price.item_code = item_code
item_price.price_list_rate = rate
item_price.insert()
bom = frappe.copy_doc(test_records[2])
bom.set_rate_of_sub_assembly_item_based_on_bom = 0
bom.rm_cost_as_per = "Price List"

View File

@ -457,7 +457,7 @@ def get_material_request_items(row, sales_order, company, ignore_existing_ordere
if row['purchase_uom'] != row['stock_uom']:
if not row['conversion_factor']:
frappe.throw(_("UOM Conversion factor ({0} -> {1}) not found for item: {2}")
.format(row['purchase_uom'], row['stock_uom'], item))
.format(row['purchase_uom'], row['stock_uom'], row.item_code))
requested_qty = requested_qty / row['conversion_factor']
if frappe.db.get_value("UOM", row['purchase_uom'], "must_be_whole_number"):
@ -546,7 +546,7 @@ def get_items_for_material_requests(doc, sales_order=None, company=None):
ignore_existing_ordered_qty = data.get('ignore_existing_ordered_qty') or doc.get('ignore_existing_ordered_qty')
planned_qty = data.get('required_qty') or data.get('planned_qty')
item_details = {}
if data.get("bom"):
if data.get("bom") or data.get("bom_no"):
if data.get('required_qty'):
bom_no = data.get('bom')
include_non_stock_items = 1
@ -563,7 +563,7 @@ def get_items_for_material_requests(doc, sales_order=None, company=None):
if data.get('include_exploded_items') and include_subcontracted_items:
# fetch exploded items from BOM
item_details = get_exploded_items(item_details,
company, bom_no,include_non_stock_items, planned_qty=planned_qty)
company, bom_no, include_non_stock_items, planned_qty=planned_qty)
else:
item_details = get_subitems(doc, data, item_details, bom_no, company,
include_non_stock_items, include_subcontracted_items, 1, planned_qty=planned_qty)
@ -591,7 +591,6 @@ def get_items_for_material_requests(doc, sales_order=None, company=None):
'conversion_factor' : conversion_factor,
}
)
if not sales_order:
sales_order = doc.get("sales_order")