mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-21 11:15:10 +00:00
fix: operation time auto set to zero (#27190)
* fix: operation time auto set to zero (#27188)
(cherry picked from commit e6799d78ef)
# Conflicts:
# erpnext/patches.txt
* fix: conflicts
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -514,17 +514,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
|
||||
|
||||
@@ -303,3 +303,4 @@ erpnext.patches.v13_0.update_recipient_email_digest
|
||||
erpnext.patches.v13_0.shopify_deprecation_warning
|
||||
erpnext.patches.v13_0.add_custom_field_for_south_africa #2
|
||||
erpnext.patches.v13_0.rename_discharge_ordered_date_in_ip_record
|
||||
erpnext.patches.v13_0.set_operation_time_based_on_operating_cost
|
||||
|
||||
@@ -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"
|
||||
''')
|
||||
Reference in New Issue
Block a user