mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
Merge pull request #24878 from anupamvs/planning
feat: add total available stock field in PO
This commit is contained in:
@@ -56,6 +56,8 @@
|
|||||||
"base_net_amount",
|
"base_net_amount",
|
||||||
"warehouse_and_reference",
|
"warehouse_and_reference",
|
||||||
"warehouse",
|
"warehouse",
|
||||||
|
"actual_qty",
|
||||||
|
"company_total_stock",
|
||||||
"material_request",
|
"material_request",
|
||||||
"material_request_item",
|
"material_request_item",
|
||||||
"sales_order",
|
"sales_order",
|
||||||
@@ -743,6 +745,22 @@
|
|||||||
"options": "currency",
|
"options": "currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"fieldname": "actual_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Available Qty at Warehouse",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"fieldname": "company_total_stock",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"label": "Available Qty at Company",
|
||||||
|
"no_copy": 1,
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"collapsible": 1,
|
"collapsible": 1,
|
||||||
"fieldname": "discount_and_margin_section",
|
"fieldname": "discount_and_margin_section",
|
||||||
@@ -791,7 +809,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-02-23 01:00:27.132705",
|
"modified": "2021-03-22 11:46:12.357435",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
|||||||
@@ -216,7 +216,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
child: item,
|
child: item,
|
||||||
args: {
|
args: {
|
||||||
item_code: item.item_code,
|
item_code: item.item_code,
|
||||||
warehouse: item.warehouse
|
warehouse: item.warehouse,
|
||||||
|
company: doc.company
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -922,10 +922,19 @@ def get_projected_qty(item_code, warehouse):
|
|||||||
{"item_code": item_code, "warehouse": warehouse}, "projected_qty")}
|
{"item_code": item_code, "warehouse": warehouse}, "projected_qty")}
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_bin_details(item_code, warehouse):
|
def get_bin_details(item_code, warehouse, company=None):
|
||||||
return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
|
bin_details = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
|
||||||
["projected_qty", "actual_qty", "reserved_qty"], as_dict=True, cache=True) \
|
["projected_qty", "actual_qty", "reserved_qty"], as_dict=True, cache=True) \
|
||||||
or {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
|
or {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
|
||||||
|
if company:
|
||||||
|
bin_details['company_total_stock'] = get_company_total_stock(item_code, company)
|
||||||
|
return bin_details
|
||||||
|
|
||||||
|
def get_company_total_stock(item_code, company):
|
||||||
|
return frappe.db.sql("""SELECT sum(actual_qty) from
|
||||||
|
(`tabBin` INNER JOIN `tabWarehouse` ON `tabBin`.warehouse = `tabWarehouse`.name)
|
||||||
|
WHERE `tabWarehouse`.company = '{0}' and `tabBin`.item_code = '{1}'"""
|
||||||
|
.format(company, item_code))[0][0]
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_serial_no_details(item_code, warehouse, stock_qty, serial_no):
|
def get_serial_no_details(item_code, warehouse, stock_qty, serial_no):
|
||||||
|
|||||||
Reference in New Issue
Block a user