Advertisement
Cadara_Ramirez

heladom - todo migration

Mar 3rd, 2022
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import frappe
  2.  
  3. def execute():
  4.     mapping = {
  5.         "High": "4 (High)",
  6.         "Medium": "3 (Normal)",
  7.         "Low": "2 (Low)"
  8.     }
  9.  
  10.     query = "select name, priority from `tabToDo` where priority is not null;"
  11.     res = frappe.db.sql(query, as_dict=True)
  12.     for todo in res:
  13.         new_priority = mapping.get(todo['priority'], False)
  14.         if new_priority:
  15.             frappe.db.set_value('ToDo', todo['name'], 'priority', new_priority)
  16.  
  17.     frappe.db.commit()
  18.  
  19.  
  20.     query = "select name, subject, reference_type, reference_name from `tabToDo` where subject is null and reference_type is not null and reference_name is not null;"
  21.     res = frappe.db.sql(query, as_dict=True)
  22.     for todo in res:
  23.         new_subject = f"{todo['reference_type']} - {todo['reference_name']}"
  24.         frappe.db.set_value('ToDo', todo['name'], 'subject', new_subject)
  25.  
  26.     frappe.db.commit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement