'Save the current document in the database in the **DocType**\'s table or
`tabSingles` (for single types).
This will check for user permissions and execute
`validate` before updating, `on_update` after updating triggers.
:param ignore_permissions: Do not check permissions if True.
:param ignore_version: Do not save version if True.'

def _save(self, ignore_permissions=None, ignore_version=None):

    if self.flags.in_print:
        return
    self.flags.email_alerts_executed = []
    if (ignore_permissions != None):
        self.flags.ignore_permissions = ignore_permissions
    if (ignore_version != None):
        self.flags.ignore_version = ignore_version
    if (self.get(u'__islocal') or (not self.get(u'name'))):
        self.insert()
        return
    self.check_permission(u'write', u'save')
    self.set_user_and_timestamp()
    self.set_docstatus()
    self.check_if_latest()
    self.set_parent_in_children()
    self.validate_higher_perm_levels()
    self.run_before_save_methods()
    if (self._action != u'cancel'):
        self._validate()
    if (self._action == u'update_after_submit'):
        self.validate_update_after_submit()
    self.set_docstatus()
    if self.meta.issingle:
        self.update_single(self.get_valid_dict())
    else:
        self.db_update()
    self.update_children()
    self.run_post_save_methods()
    return self
