set qty as per stock uom in entire purchase cycle

This commit is contained in:
nabinhait 2014-07-14 10:47:50 +05:30
parent e6cee7b41f
commit 614fb750b7
2 changed files with 9 additions and 0 deletions

View File

@ -17,6 +17,7 @@ class BuyingController(StockController):
self.supplier_name = frappe.db.get_value("Supplier",
self.supplier, "supplier_name")
self.is_item_table_empty()
self.set_qty_as_per_stock_uom()
self.validate_stock_or_nonstock_items()
self.validate_warehouse()
@ -317,3 +318,10 @@ class BuyingController(StockController):
def is_item_table_empty(self):
if not len(self.get(self.fname)):
frappe.throw(_("Item table can not be blank"))
def set_qty_as_per_stock_uom(self):
for d in self.get(self.fname):
if d.meta.get_field("stock_qty") and not d.stock_qty:
if not d.conversion_factor:
frappe.throw(_("Row {0}: Conversion Factor is mandatory"))
d.stock_qty = flt(d.qty) * flt(d.conversion_factor)

View File

@ -152,6 +152,7 @@ def get_basic_details(args, item_doc):
"min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "",
"conversion_factor": 1.0,
"qty": 1.0,
"stock_qty": 1.0,
"price_list_rate": 0.0,
"base_price_list_rate": 0.0,
"rate": 0.0,