Merge pull request #22607 from AfshanKhan/club-mr-column
feat: added columns to get complete analysis for material request
This commit is contained in:
commit
60af68bc48
@ -2,7 +2,7 @@
|
||||
// For license information, please see license.txt
|
||||
/* eslint-disable */
|
||||
|
||||
frappe.query_reports["Requested Items to Order"] = {
|
||||
frappe.query_reports["Requested Items to Order and Receive"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname": "company",
|
@ -1,21 +1,21 @@
|
||||
{
|
||||
"add_total_row": 1,
|
||||
"creation": "2020-05-04 20:23:57.750719",
|
||||
"creation": "2020-07-10 14:28:21.041310",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2020-05-05 13:05:51.723951",
|
||||
"modified": "2020-07-10 14:28:21.041310",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Requested Items to Order",
|
||||
"name": "Requested Items to Order and Receive",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"query": "",
|
||||
"ref_doctype": "Material Request",
|
||||
"report_name": "Requested Items to Order",
|
||||
"report_name": "Requested Items to Order and Receive",
|
||||
"report_type": "Script Report",
|
||||
"roles": [
|
||||
{
|
@ -59,8 +59,11 @@ def get_data(filters, conditions):
|
||||
sum(ifnull(mr_item.stock_qty, 0)) as qty,
|
||||
ifnull(mr_item.stock_uom, '') as uom,
|
||||
sum(ifnull(mr_item.ordered_qty, 0)) as ordered_qty,
|
||||
(sum(mr_item.stock_qty) - sum(ifnull(mr_item.ordered_qty, 0))) as qty_to_order,
|
||||
sum(ifnull(mr_item.received_qty, 0)) as received_qty,
|
||||
(sum(ifnull(mr_item.stock_qty, 0)) - sum(ifnull(mr_item.received_qty, 0))) as qty_to_receive,
|
||||
(sum(ifnull(mr_item.stock_qty, 0)) - sum(ifnull(mr_item.ordered_qty, 0))) as qty_to_order,
|
||||
mr_item.item_name as item_name,
|
||||
mr_item.description as "description",
|
||||
mr.company as company
|
||||
from
|
||||
`tabMaterial Request` mr, `tabMaterial Request Item` mr_item
|
||||
@ -78,7 +81,7 @@ def get_data(filters, conditions):
|
||||
return data
|
||||
|
||||
def update_qty_columns(row_to_update, data_row):
|
||||
fields = ["qty", "ordered_qty", "qty_to_order"]
|
||||
fields = ["qty", "ordered_qty", "received_qty", "qty_to_receive", "qty_to_order"]
|
||||
for field in fields:
|
||||
row_to_update[field] += flt(data_row[field])
|
||||
|
||||
@ -92,7 +95,9 @@ def prepare_data(data, filters):
|
||||
item_qty_map[row["item_code"]] = {
|
||||
"qty" : row["qty"],
|
||||
"ordered_qty" : row["ordered_qty"],
|
||||
"qty_to_order" : row["qty_to_order"]
|
||||
"received_qty": row["received_qty"],
|
||||
"qty_to_receive": row["qty_to_receive"],
|
||||
"qty_to_order" : row["qty_to_order"],
|
||||
}
|
||||
else:
|
||||
item_entry = item_qty_map[row["item_code"]]
|
||||
@ -122,7 +127,7 @@ def prepare_data(data, filters):
|
||||
return data, chart_data
|
||||
|
||||
def prepare_chart_data(item_data):
|
||||
labels, qty_to_order, ordered_qty = [], [], []
|
||||
labels, qty_to_order, ordered_qty, received_qty, qty_to_receive = [], [], [], [], []
|
||||
|
||||
if len(item_data) > 30:
|
||||
item_data = dict(list(item_data.items())[:30])
|
||||
@ -132,6 +137,8 @@ def prepare_chart_data(item_data):
|
||||
labels.append(row)
|
||||
qty_to_order.append(mr_row["qty_to_order"])
|
||||
ordered_qty.append(mr_row["ordered_qty"])
|
||||
received_qty.append(mr_row["received_qty"])
|
||||
qty_to_receive.append(mr_row["qty_to_receive"])
|
||||
|
||||
chart_data = {
|
||||
"data" : {
|
||||
@ -144,6 +151,14 @@ def prepare_chart_data(item_data):
|
||||
{
|
||||
'name': _('Ordered Qty'),
|
||||
'values': ordered_qty
|
||||
},
|
||||
{
|
||||
'name': _('Received Qty'),
|
||||
'values': received_qty
|
||||
},
|
||||
{
|
||||
'name': _('Qty to Receive'),
|
||||
'values': qty_to_receive
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -193,7 +208,13 @@ def get_columns(filters):
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": _("UOM"),
|
||||
"label": _("Description"),
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Data",
|
||||
"width": 200
|
||||
},
|
||||
{
|
||||
"label": _("Stock UOM"),
|
||||
"fieldname": "uom",
|
||||
"fieldtype": "Data",
|
||||
"width": 100,
|
||||
@ -201,7 +222,7 @@ def get_columns(filters):
|
||||
|
||||
columns.extend([
|
||||
{
|
||||
"label": _("Qty"),
|
||||
"label": _("Stock Qty"),
|
||||
"fieldname": "qty",
|
||||
"fieldtype": "Float",
|
||||
"width": 120,
|
||||
@ -214,6 +235,20 @@ def get_columns(filters):
|
||||
"width": 120,
|
||||
"convertible": "qty"
|
||||
},
|
||||
{
|
||||
"label": _("Received Qty"),
|
||||
"fieldname": "received_qty",
|
||||
"fieldtype": "Float",
|
||||
"width": 120,
|
||||
"convertible": "qty"
|
||||
},
|
||||
{
|
||||
"label": _("Qty to Receive"),
|
||||
"fieldname": "qty_to_receive",
|
||||
"fieldtype": "Float",
|
||||
"width": 120,
|
||||
"convertible": "qty"
|
||||
},
|
||||
{
|
||||
"label": _("Qty to Order"),
|
||||
"fieldname": "qty_to_order",
|
@ -708,5 +708,6 @@ erpnext.patches.v13_0.move_doctype_reports_and_notification_from_hr_to_payroll #
|
||||
erpnext.patches.v13_0.move_payroll_setting_separately_from_hr_settings #22-06-2020
|
||||
erpnext.patches.v13_0.check_is_income_tax_component #22-06-2020
|
||||
erpnext.patches.v12_0.add_taxjar_integration_field
|
||||
erpnext.patches.v13_0.delete_report_requested_items_to_order
|
||||
erpnext.patches.v12_0.update_item_tax_template_company
|
||||
erpnext.patches.v13_0.move_branch_code_to_bank_account
|
||||
|
@ -0,0 +1,12 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
""" Check for one or multiple Auto Email Reports and delete """
|
||||
auto_email_reports = frappe.db.get_values("Auto Email Report", {"report": "Requested Items to Order"}, ["name"])
|
||||
for auto_email_report in auto_email_reports:
|
||||
frappe.delete_doc("Auto Email Report", auto_email_report[0])
|
||||
|
||||
frappe.db.sql("""
|
||||
DELETE FROM `tabReport`
|
||||
WHERE name = 'Requested Items to Order'
|
||||
""")
|
Loading…
Reference in New Issue
Block a user