AttributeError: 'dict' object has no attribute 'modified'

Hi All,
i am try to update document in server side . but i am getting error as below
AttributeError: ‘dict’ object has no attribute ‘modified’
i see this error is coming while updating child table values. here is my code

risk_assesment_doc = frappe.get_doc('Risk Assesment', 'RA-2021-00028')
risk_assesment_doc.assesment_detail = assesment_detail //value for child table
risk_assesment_doc.total = total_score
risk_assesment_doc.save()
frappe.db.commit()

inserting new document is working fine, but updating is not working

  File "/home/frappe/bench-v12/apps/frappe/frappe/model/document.py", line 449, in 
  set_user_and_timestamp
  d.modified = self.modified
  AttributeError: 'dict' object has no attribute 'modified'

I face the same issue. any luck ?

I’m my case I have also used frappe.db.set_value before the above and I did after the code, then it’s worked

@abrarpv97 Can you share the code that works?

@s_Mafutta you can use
frappe.db.set_value(‘Supplier’, name, ‘field_name’, value). please let me know what is your exact use case

In my case I had this issue when trying to add a line to a Stock Entry in a Before Submit handler.

Examining the code at the indicated line I realized that the dict object lacking the modified attribute was, in fact, the new line I was trying to add.

I added, a modified attribute, but immediately got back:

AttributeError: ‘dict’ object has no attribute ‘name’

I added, a name attribute, but got back yet another missing item.

Looking further, I learned that you cannot do …

doc.items.append(newRow)

… because the supported syntax is …

 doc.append('items', newRow)
1 Like