'sync tasks and remove table'

def sync_tasks(self):

    if self.flags.dont_sync_tasks:
        return
    task_names = []
    for t in self.tasks:
        if t.task_id:
            task = frappe.get_doc(u'Task', t.task_id)
        else:
            task = frappe.new_doc(u'Task')
            task.project = self.name
        task.update({u'subject': t.title, u'status': t.status, u'exp_start_date': t.start_date, u'exp_end_date': t.end_date, u'description': t.description, u'task_weight': t.task_weight})
        self.map_custom_fields(t, task)
        task.flags.ignore_links = True
        task.flags.from_project = True
        task.flags.ignore_feed = True
        task.save(ignore_permissions=True)
        task_names.append(task.name)
    for t in frappe.get_all(u'Task', [u'name'], {u'project': self.name, u'name': (u'not    in', task_names)}):
        frappe.delete_doc(u'Task', t.name)
    self.update_percent_complete()
    self.update_costing()
