fix: operation time auto set to zero (#27188)

This commit is contained in:
rohitwaghchaure 2021-08-27 10:46:45 +05:30 committed by GitHub
parent ae7ec8e44d
commit e6799d78ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View File

@ -517,17 +517,21 @@ class BOM(WebsiteGenerator):
def update_rate_and_time(self, row, update_hour_rate = False):
if not row.hour_rate or update_hour_rate:
hour_rate = flt(frappe.get_cached_value("Workstation", row.workstation, "hour_rate"))
row.hour_rate = (hour_rate / flt(self.conversion_rate)
if self.conversion_rate and hour_rate else hour_rate)
if hour_rate:
row.hour_rate = (hour_rate / flt(self.conversion_rate)
if self.conversion_rate and hour_rate else hour_rate)
if self.routing:
row.time_in_mins = flt(frappe.db.get_value("BOM Operation", {
time_in_mins = flt(frappe.db.get_value("BOM Operation", {
"workstation": row.workstation,
"operation": row.operation,
"sequence_id": row.sequence_id,
"parent": self.routing
}, ["time_in_mins"]))
if time_in_mins:
row.time_in_mins = time_in_mins
if row.hour_rate and row.time_in_mins:
row.base_hour_rate = flt(row.hour_rate) * flt(self.conversion_rate)
row.operating_cost = flt(row.hour_rate) * flt(row.time_in_mins) / 60.0

View File

@ -299,3 +299,4 @@ erpnext.patches.v13_0.migrate_stripe_api
erpnext.patches.v13_0.reset_clearance_date_for_intracompany_payment_entries
erpnext.patches.v13_0.einvoicing_deprecation_warning
erpnext.patches.v14_0.delete_einvoicing_doctypes
erpnext.patches.v13_0.set_operation_time_based_on_operating_cost

View File

@ -0,0 +1,15 @@
import frappe
def execute():
frappe.reload_doc('manufacturing', 'doctype', 'bom')
frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
frappe.db.sql('''
UPDATE
`tabBOM Operation`
SET
time_in_mins = (operating_cost * 60) / hour_rate
WHERE
time_in_mins = 0 AND operating_cost > 0
AND hour_rate > 0 AND docstatus = 1 AND parenttype = "BOM"
''')