Hello everybody
Trying to insert into my custom doctype using python script opens json file then insert each record into database but i got this error
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 219, in insert
self._set_defaults()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 627, in _set_defaults
d.update_if_missing(new_doc)
AttributeError: ‘dict’ object has no attribute ‘update_if_missing’
my code snippet:
def execute():
with open(os.path.join(sys.path[0], "/home/frappe/frappe-
bench/apps/custom/custom_app/patches/mapping.json"), "r") as f:
data = json.load(f)
for x in data['feature_mapping']:
print (x['feature'])
doc=frappe.get_doc({
"doctype": "Mapping",
"feature":x['feature'],
"app_name":x["app_name"],
"roles":x["roles"]
})
if x['allow_totp']=='Yes':
doc.allow_totp=x["allow_totp"]
doc.authenticator_roles=x["authenticator_roles"]
doc.insert( ignore_permissions=True, # ignore write permissions during insert
ignore_links=True, # ignore Link validation in the document
ignore_if_duplicate=True, # dont insert if DuplicateEntryError is thrown
)
frappe.db.commit()
execute()