Set frappe.flags.in_patch when running a patch