It’s easy to test.
In [1]: doc = frappe.new_doc('Task')
In [2]: doc.subject = 'Testing new'
In [3]: doc.as_dict()
Out[3]:
{'name': None,
'owner': 'Administrator',
'creation': None,
'modified': None,
'modified_by': None,
'parent': None,
'parentfield': None,
'parenttype': None,
'idx': 0,
'docstatus': 0,
'github_sync_id': None,
'subject': 'Testing new',
'project': None,
'issue': None,
'type': None,
'is_group': 0,
'status': 'Open',
'priority': 'Low',
'task_weight': 0,
'completed_by': None,
'color': None,
'parent_task': None,
'exp_start_date': None,
'expected_time': 0.0,
'exp_end_date': None,
'progress': 0,
'is_milestone': 0,
'description': None,
'depends_on_tasks': None,
'act_start_date': None,
'actual_time': 0,
'act_end_date': None,
'total_costing_amount': 0,
'total_expense_claim': 0,
'total_billing_amount': 0,
'review_date': None,
'closing_date': None,
'department': None,
'company': 'Login Cargo',
'lft': 0,
'rgt': 0,
'old_parent': None,
'doctype': 'Task',
'depends_on': [],
'__islocal': 1} # Here it is
In [4]: doc.is_new()
Out[4]: 1
In [5]: doc.save()
In [6]: doc.is_new() # As you can see is not new anymore
In [7]: doc.as_dict()
Out[7]:
{'name': 'TASK-2020-00001',
'owner': 'Administrator',
'creation': datetime.datetime(2020, 7, 22, 10, 42, 18, 556870),
'modified': datetime.datetime(2020, 7, 22, 10, 42, 18, 585971),
'modified_by': 'Administrator',
'parent': None,
'parentfield': None,
'parenttype': None,
'idx': 0,
'docstatus': 0,
'github_sync_id': None,
'subject': 'Testing new',
'project': None,
'issue': None,
'type': None,
'is_group': 0,
'status': 'Open',
'priority': 'Low',
'task_weight': 0.0,
'completed_by': None,
'color': None,
'parent_task': None,
'exp_start_date': None,
'expected_time': 0.0,
'exp_end_date': None,
'progress': 0.0,
'is_milestone': 0,
'description': None,
'depends_on_tasks': '',
'act_start_date': None,
'actual_time': 0.0,
'act_end_date': None,
'total_costing_amount': 0.0,
'total_expense_claim': 0.0,
'total_billing_amount': 0.0,
'review_date': None,
'closing_date': None,
'department': None,
'company': 'Login Cargo',
'lft': 1,
'rgt': 2,
'old_parent': '',
'doctype': 'Task',
'depends_on': []} # __islocal is __isgone lol
But check what happens if the document is created with get_doc
as specified in the documentation
In [1]: doc = frappe.get_doc(doctype='Task', subject='Testing')
In [2]: doc.is_new()
In [3]: doc.as_dict()
Out[3]:
{'name': None,
'owner': None,
'creation': None,
'modified': None,
'modified_by': None,
'parent': None,
'parentfield': None,
'parenttype': None,
'idx': 0,
'docstatus': 0,
'github_sync_id': None,
'subject': 'Testing',
'project': None,
'issue': None,
'type': None,
'is_group': 0,
'status': None,
'priority': None,
'task_weight': 0,
'completed_by': None,
'color': None,
'parent_task': None,
'exp_start_date': None,
'expected_time': 0,
'exp_end_date': None,
'progress': 0,
'is_milestone': 0,
'description': None,
'depends_on_tasks': None,
'act_start_date': None,
'actual_time': 0,
'act_end_date': None,
'total_costing_amount': 0,
'total_expense_claim': 0,
'total_billing_amount': 0,
'review_date': None,
'closing_date': None,
'department': None,
'company': None,
'lft': 0,
'rgt': 0,
'old_parent': None,
'doctype': 'Task',
'depends_on': []}
In [4]: doc.save()
So because is new can be unreliable. I’d rather check if it’s in the database.