Error: Document has been modified after you have opened it

Writing Child doc info of same Parent doc info , using for loop from javascript.

  1. Opened Parent doc using get_doc
  2. Opened Child doc using new_doc
  3. Append Child doc to Parent doc
  4. Save Parent doc

Above works fine, if send Child info for different Parents from js.
But only one Child doc info get written, if send multiple Child doc info for same Parent.

Hi @Nitto,

Share your code

Drag multiple photos together to upload.
Works fine if upload one at a time.

   function fileUploaded(data){

   for (var i=0,f; f = files[i]; i++) {
      upload_args = {
                 "filename" :,
         args: upload_args,
         callback: fileUploaded

def upload_photo(filename):
    parent_doc = frappe.get_doc(‘DOC A’, ‘parent A’)
    child_doc = frappe.new_doc(‘DOC B’)
    child_doc.photo_name = filename
    parent_doc.append(‘photos’, child_doc)

@Nitto, is an asynchronous method. try passing the list of filename to upload_photo method and iterate the files in python instead of js.

Thanks, Makarand

what if there’s a restriction on doing it from js only, whats the other option?
lets say the call is made to update the same doctype multiple times, whats the way to achieve this?