I’m using a custom app vehicle_management_app. After some changes, all my Fuel Log Items (tabFuel Log Item) are present in the database, but the parent Fuel Logs (tabFuel Log) are missing.For example:
SELECT DISTINCT parent FROM `tabFuel Log Item`;
Shows hundreds of parent IDs like FUEL-0001, FUEL-0673, etc.
However, running in Frappe:
frappe.get_all("Fuel Log")
Returns almost nothing. Attempts to recreate missing parent Fuel Log documents programmatically only created 1 or very few entries, far fewer than expected.
Database state:
-
tabFuel Log: mostly empty -
tabFuel Log Item: contains all expected records
My goal:
I want to restore all missing Fuel Log documents for each parent referenced in Fuel Log Item, without losing any data.
Questions:
-
What’s the best Frappe-safe way to recreate missing parent documents from existing child items?
-
Should I use a patch, a Python script, or SQL for this?
-
How can I batch-create these parents while keeping all child items linked correctly?
Any guidance or sample approach would be very helpful.