fix: asset maintenance TypeError during date comparisons (#19098)
This commit is contained in:
parent
d793e39b6d
commit
1ba83427e5
@ -57,7 +57,7 @@ def calculate_next_due_date(periodicity, start_date = None, end_date = None, las
|
|||||||
if not start_date and not last_completion_date:
|
if not start_date and not last_completion_date:
|
||||||
start_date = frappe.utils.now()
|
start_date = frappe.utils.now()
|
||||||
|
|
||||||
if last_completion_date and (last_completion_date > start_date or not start_date):
|
if last_completion_date and ((start_date and last_completion_date > start_date) or not start_date):
|
||||||
start_date = last_completion_date
|
start_date = last_completion_date
|
||||||
if periodicity == 'Daily':
|
if periodicity == 'Daily':
|
||||||
next_due_date = add_days(start_date, 1)
|
next_due_date = add_days(start_date, 1)
|
||||||
@ -71,10 +71,11 @@ def calculate_next_due_date(periodicity, start_date = None, end_date = None, las
|
|||||||
next_due_date = add_years(start_date, 2)
|
next_due_date = add_years(start_date, 2)
|
||||||
if periodicity == 'Quarterly':
|
if periodicity == 'Quarterly':
|
||||||
next_due_date = add_months(start_date, 3)
|
next_due_date = add_months(start_date, 3)
|
||||||
if end_date and (start_date >= end_date or last_completion_date >= end_date or next_due_date):
|
if end_date and ((start_date and start_date >= end_date) or (last_completion_date and last_completion_date >= end_date) or next_due_date):
|
||||||
next_due_date = ""
|
next_due_date = ""
|
||||||
return next_due_date
|
return next_due_date
|
||||||
|
|
||||||
|
|
||||||
def update_maintenance_log(asset_maintenance, item_code, item_name, task):
|
def update_maintenance_log(asset_maintenance, item_code, item_name, task):
|
||||||
asset_maintenance_log = frappe.get_value("Asset Maintenance Log", {"asset_maintenance": asset_maintenance,
|
asset_maintenance_log = frappe.get_value("Asset Maintenance Log", {"asset_maintenance": asset_maintenance,
|
||||||
"task": task.maintenance_task, "maintenance_status": ('in',['Planned','Overdue'])})
|
"task": task.maintenance_task, "maintenance_status": ('in',['Planned','Overdue'])})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user