share_9.py 764 B

1234567891011121314151617181920212223
  1. def notify_assignment(shared_by, doctype, doc_name, everyone):
  2. if not (shared_by and doctype and doc_name) or everyone: return
  3. from frappe.utils import get_fullname
  4. title_field = frappe.get_meta(doctype).get_title_field()
  5. title = doc_name if title_field == "name" else \
  6. frappe.db.get_value(doctype, doc_name, title_field)
  7. reference_user = get_fullname(frappe.session.user)
  8. notification_message = _('{0} shared a document {1} {2} with you').format(
  9. frappe.bold(reference_user), frappe.bold(doctype), frappe.bold(title))
  10. notification_doc = {
  11. 'type': 'Share',
  12. 'document_type': doctype,
  13. 'subject': notification_message,
  14. 'document_name': doc_name,
  15. 'from_user': frappe.session.user
  16. }
  17. enqueue_create_notification(shared_by, notification_doc)