def add_user_permission(doctype, name, user, with_message=False):
 if (name not in frappe.defaults.get_user_permissions(user).get(doctype, [])):
  if (not frappe.db.exists(doctype, name)):
   frappe.throw(_(u'{0} {1} not found').format(_(doctype), name), frappe.DoesNotExistError)
  frappe.defaults.add_default(doctype, name, user, u'User Permission')
 elif with_message:
  msgprint(_(u'Permission already set'))

def add_user_permission ( doctype , name , user , with_message = False ) : if ( name not in frappe . defaults . get_user_permissions ( user ) . get ( doctype , [ ] ) ) : if ( not frappe . db . exists ( doctype , name ) ) : frappe . throw ( _ ( u'{0} {1} not found' ) . format ( _ ( doctype ) , name ) , frappe . DoesNotExistError ) frappe . defaults . add_default ( doctype , name , user , u'User Permission' ) elif with_message : msgprint ( _ ( u'Permission already set' ) )
add user default .