User Permission for Custom Button in Submittable Doctype

I have a submittable doctype used by different users
The doctype has a custom button added via the script

User A has read,write permissions on the doctype
User B has **read,write,submit,cancel,permission on the doctype

User A receives get a permission error if he attempts to use the custom button see screenshot below

User B can use the custom buttons without any issue

How do I give user A access to use the custom button,without having to give submit permission

The code which generates this error is referenced here,does not have access to this document

in the method for the custom button
I’ve tried setting

self.flags.ignore_permissions = True
frappe.session.user = ‘Administrator’

Settings this values should normally override the permissions check

Has anyone else had this issue and how did you resolve?