Update new bom rate while replacing BOM (#11045)
This commit is contained in:
parent
d3e21fff66
commit
7e5a9f5c0e
@ -30,12 +30,13 @@ class BOMUpdateTool(Document):
|
||||
frappe.throw(_("The selected BOMs are not for the same item"))
|
||||
|
||||
def update_new_bom(self):
|
||||
current_bom_unitcost = frappe.db.sql("""select total_cost/quantity
|
||||
from `tabBOM` where name = %s""", self.current_bom)
|
||||
current_bom_unitcost = current_bom_unitcost and flt(current_bom_unitcost[0][0]) or 0
|
||||
new_bom_unitcost = frappe.db.sql("""select total_cost/quantity
|
||||
from `tabBOM` where name = %s""", self.new_bom)
|
||||
new_bom_unitcost = flt(new_bom_unitcost[0][0]) if new_bom_unitcost else 0
|
||||
|
||||
frappe.db.sql("""update `tabBOM Item` set bom_no=%s,
|
||||
rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2""",
|
||||
(self.new_bom, current_bom_unitcost, current_bom_unitcost, self.current_bom))
|
||||
(self.new_bom, new_bom_unitcost, new_bom_unitcost, self.current_bom))
|
||||
|
||||
def get_parent_boms(self):
|
||||
return [d[0] for d in frappe.db.sql("""select distinct parent
|
||||
|
Loading…
x
Reference in New Issue
Block a user