Dear @Masky ,
The correct way to solve this is adding permision inside doctype settings. If that is not possible for you then you add customdocperms inside your hooks. For Ref…
The “Vehicle” doctype is part of the ERPNext > Setup module, and I don’t want to modify the core files. Consequently, I attempted to add it to the Custom DocPerm. However, after each migration, the permission for it was consistently being removed.
I have successfully resolved the problem, and I would like to share the solution for the benefit of others encountering a similar issue.
Resolution:
The root cause of the problem was identified in some customizations of the vehicle doctype. It turns out that in a previously exported file, the new permissions were missing. During the migration process, Frappe checked this file for permissions and removed the missing ones, leading to the observed behavior.
Solution:
I revisited the exported file, ensured that it included the necessary permissions for the vehicle doctype, and then re-ran the migration. This resolved the issue, and the custom DocPerms are now retained as expected.