Understanding frappe.flags.ignore_permissions

How does frappe.flags.ignore_permissions works? I am trying to generate Payment Entry

from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry

payment_entry = get_payment_entry("Sales Invoice", sales_invoice.name).as_dict()

I get frappe.exceptions.PermissionError. For some reason it used to work before. As in days ago. And I did not update any version.

UPDATE 1: I can also use frappe.set_user("Administrator")

Update your app and pass the ignore_permissions=True argument when calling the function.