Digging around code a little more… I think maybe it’s not too large of a task. I think good approach could be:
- Create a GROUP called “RestrictedViews”
- Add users to this group who we wish to only read document objects where they are the fk_user_author
Then for each type of document object (i.e. purchase order) in the function where the table rows are being SELECTED for listing/displaying the the user, we first perform a check if $this_user_id is member of $group_RestrictedViews then instead of pulling all of the rows from the table, we add WHERE fk_user_author = $this_user_id
This is basic concept of “easy” way.
Of course more things to consider and add ACL check wrapper around like functions where the restricted user can update, delete, etc. but seems straightforward.
If this were a module, I guess the module setup values would ask:
Group name of users restricted to their own objects/documents: [ select groupname ]
Document types/Objects to restrict:
[ ] Purchase Order Read
[ ] Purchase Order Update
[ ] Purchase Order Delete
[ ] Vendor Invoice Read
[ ] Vendor Invoice Update
[ ] Vendor Invoice Delete
It gets more tricky with vendor invoice, because I think typically an administrative/secretary person (with full unrestricted access to the Commerce and Billing/Payment modules) will be opening bills from vendors, and entering them into the system (so that person becomes $fk_user_author for the INVOICE object in dolibarr) but actually the PO linked to that invoice was authored by someone who is restrictedView and good for that person to see that invoice as well.
So with vendor invoices ACL check it is probably good to use the linked PO $fk_user_author for the ACL actions rather than the $fk_user_author on the invoice itself.
Very impressed with the Dolibarr documentation. This helps point someone in right direction to create such a module:
This shows the purchase order list… where fk_user_author is user id# of original creator:
This shows the invoice list, also fk_user_author also exists here, but as mentioned above, because a 3rd person who is opening bills, scanning documents, and making (authoring) invoice records… maybe it is better we look at the linked fk_user_author of the linked PO to determine if invoice(s) will be able to be shown to user or not…
