mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 14:08:29 +00:00
fix: update project costing based on child table field and not parent level
This commit is contained in:
@@ -216,6 +216,11 @@ class StockEntry(StockController, SubcontractingInwardController):
|
|||||||
if self.get("items") and apply_rule:
|
if self.get("items") and apply_rule:
|
||||||
apply_putaway_rule(self.doctype, self.get("items"), self.company, purpose=self.purpose)
|
apply_putaway_rule(self.doctype, self.get("items"), self.company, purpose=self.purpose)
|
||||||
|
|
||||||
|
if self.project:
|
||||||
|
for item in self.items:
|
||||||
|
if not item.project:
|
||||||
|
item.project = self.project
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.pro_doc = frappe._dict()
|
self.pro_doc = frappe._dict()
|
||||||
if self.work_order:
|
if self.work_order:
|
||||||
@@ -525,15 +530,16 @@ class StockEntry(StockController, SubcontractingInwardController):
|
|||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.project:
|
projects = set(item.project for item in self.items if item.project)
|
||||||
|
for project in projects:
|
||||||
amount = frappe.db.sql(
|
amount = frappe.db.sql(
|
||||||
""" select ifnull(sum(sed.amount), 0)
|
""" select ifnull(sum(amount), 0)
|
||||||
from
|
from
|
||||||
`tabStock Entry` se, `tabStock Entry Detail` sed
|
`tabStock Entry Detail`
|
||||||
where
|
where
|
||||||
se.docstatus = 1 and se.project = %s and sed.parent = se.name
|
docstatus = 1 and project = %s
|
||||||
and (sed.t_warehouse is null or sed.t_warehouse = '')""",
|
and (t_warehouse is null or t_warehouse = '')""",
|
||||||
self.project,
|
project,
|
||||||
as_list=1,
|
as_list=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -545,14 +551,14 @@ class StockEntry(StockController, SubcontractingInwardController):
|
|||||||
where
|
where
|
||||||
se.docstatus = 1 and se.project = %s and sed.parent = se.name
|
se.docstatus = 1 and se.project = %s and sed.parent = se.name
|
||||||
and se.purpose = 'Manufacture'""",
|
and se.purpose = 'Manufacture'""",
|
||||||
self.project,
|
project,
|
||||||
as_list=1,
|
as_list=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
additional_cost_amt = additional_costs[0][0] if additional_costs else 0
|
additional_cost_amt = additional_costs[0][0] if additional_costs else 0
|
||||||
|
|
||||||
amount += additional_cost_amt
|
amount += additional_cost_amt
|
||||||
project = frappe.get_doc("Project", self.project)
|
project = frappe.get_doc("Project", project)
|
||||||
project.total_consumed_material_cost = amount
|
project.total_consumed_material_cost = amount
|
||||||
project.save()
|
project.save()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user