1234567891011121314151617181920212223242526 |
- def get_shared(doctype, user=None, rights=None):
- """Get list of shared document names for given user and DocType.
- :param doctype: DocType of which shared names are queried.
- :param user: User for which shared names are queried.
- :param rights: List of rights for which the document is shared. List of `read`, `write`, `share`"""
- if not user:
- user = frappe.session.user
- if not rights:
- rights = ["read"]
- filters = [[right, '=', 1] for right in rights]
- filters += [['share_doctype', '=', doctype]]
- or_filters = [['user', '=', user]]
- if user != 'Guest':
- or_filters += [['everyone', '=', 1]]
- shared_docs = frappe.db.get_all('DocShare',
- fields=['share_name'],
- filters=filters,
- or_filters=or_filters)
- return [doc.share_name for doc in shared_docs]
|