Creating a back-to-back txn for a company that the user does not have access to

HI,

Scenario
Customer has two companies that have a vendor - customer relationship on the ERPNext instance. So when a user who has access to only one company C ( the customer company ) creates a PO against company V ( the vendor company ) , the system should automatically create a sales order. However the user who creates the PO does not have rights to create the SO on Company V.

Question
If we have an extension which creates the SO on submit, is it possible that it can be done with another user-id ( say a system user id ) , so that it is not restricted by the input user’s privileges? Would it work if we do the SO creation as a background task ?

Yes, It can be accomplished using code, doc.save() has an ignore_permissions flag, that you can set to True and bypass any permission issues. Also other methods to query can use said flag, is all in the docs.

1 Like