Merge pull request #24878 from anupamvs/planning

feat: add total available stock field in PO
This commit is contained in:
rohitwaghchaure 2021-04-15 16:28:49 +05:30 committed by GitHub
commit 72929aab38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 4 deletions

View File

@ -56,6 +56,8 @@
"base_net_amount",
"warehouse_and_reference",
"warehouse",
"actual_qty",
"company_total_stock",
"material_request",
"material_request_item",
"sales_order",
@ -743,6 +745,22 @@
"options": "currency",
"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,
"fieldname": "discount_and_margin_section",
@ -791,7 +809,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2021-02-23 01:00:27.132705",
"modified": "2021-03-22 11:46:12.357435",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item",

View File

@ -216,7 +216,8 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
child: item,
args: {
item_code: item.item_code,
warehouse: item.warehouse
warehouse: item.warehouse,
company: doc.company
}
});
}

View File

@ -922,10 +922,19 @@ def get_projected_qty(item_code, warehouse):
{"item_code": item_code, "warehouse": warehouse}, "projected_qty")}
@frappe.whitelist()
def get_bin_details(item_code, warehouse):
return frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
def get_bin_details(item_code, warehouse, company=None):
bin_details = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
["projected_qty", "actual_qty", "reserved_qty"], as_dict=True, cache=True) \
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()
def get_serial_no_details(item_code, warehouse, stock_qty, serial_no):