Added consumed material cost in project (#13365)
diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json
index 5d95bd3..bec7b37 100644
--- a/erpnext/projects/doctype/project/project.json
+++ b/erpnext/projects/doctype/project/project.json
@@ -1125,6 +1125,36 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "total_consumed_material_cost",
+ "fieldtype": "Currency",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Total Consumed Material Cost (via Stock Entry)",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@@ -1285,7 +1315,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 4,
- "modified": "2017-12-10 08:40:46.843201",
+ "modified": "2018-03-22 11:44:38.723507",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 5aeba7c..d1dcb31 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -74,6 +74,7 @@
if self.purchase_order and self.purpose == "Subcontract":
self.update_purchase_order_supplied_items()
self.make_gl_entries()
+ self.update_cost_in_project()
def on_cancel(self):
self.update_stock_ledger()
@@ -97,6 +98,18 @@
item.transfer_qty = flt(flt(item.qty) * flt(item.conversion_factor),
self.precision("transfer_qty", item))
+ def update_cost_in_project(self):
+ if self.project:
+ amount = frappe.db.sql(""" select ifnull(sum(sed.amount), 0)
+ from
+ `tabStock Entry` se, `tabStock Entry Detail` sed
+ where
+ se.docstatus = 1 and se.project = %s and sed.parent = se.name
+ and (sed.t_warehouse is null or sed.t_warehouse = '')""", self.project, as_list=1)
+
+ if amount:
+ frappe.db.set_value('Project', self.project, 'total_consumed_material_cost', amount[0][0])
+
def validate_item(self):
stock_items = self.get_stock_items()
serialized_items = self.get_serialized_items()