       # Attacher un ecouteur evenement sur les checkbox des items
       E.delegateListener root, 'click', ".item-checkbox", (e) =>
         commandContainer = e.target.closest('.model')
-        syncState(commandContainer)
+        syncState(commandContainer, $form)
         return
 
       # Handle automated selection of multiple checkbox
       E.delegateListener root, 'click', '.model-checkbox', (e) =>
         checked = e.target.checked
         commandContainer = e.target.closest('.model')
-        setAllChildrenTo(commandContainer, checked) 
+        setAllChildrenTo(commandContainer, checked, $form) 
         return
 
       displayedItemIds = Array.from(document.querySelectorAll('.nested-fields .nested-item-form[data-item-id]'))
       displayedItemIds = displayedItemIds.map((item) => item.dataset.itemId)
 
       displayedItemIds.forEach (id) => 
-        checkbox = content.querySelector("input[type='checkbox'][data-id='#{id}']")
+        checkbox = content.querySelector(".item input[type='checkbox'][data-id='#{id}']")
         commandContainer = checkbox.closest('.model')
         if checkbox
           checkbox.checked = true
-          syncState(commandContainer)
+          syncState(commandContainer, $form)
       return
 
     prom.then (modal) =>

    closePurchaseOrderBlock.querySelector("input[type='radio'][value=#{value}").checked = true

  # Sets all children checkboxes to 'value' and sync state
  setAllChildrenTo = (commandContainer, value) =>
    commandContainer.querySelectorAll('.item-checkbox').forEach((item) => item.checked = value)
    syncState(commandContainer)

  E.reconciliation =
    reconciliateItems: (modalContent) ->

      data['reception'] = action.substr(action.lastIndexOf('/') + 1)
    {url: url, data: data}

  isPurchaseInvoiceForm = ($form) => 
    $form.closest('.simple_form').is('.new_purchase_invoice, .edit_purchase_invoice')
  
  isReceptionForm = ($form) => 
    $form.closest('.simple_form').is('.new_reception, .edit_reception')
  
  # Returns a promise that resolves to the content for the modal to be opened
  content_for_reconciliation_modal = ($form) =>
    options = {}
    if isPurchaseInvoiceForm($form)
      options = purchase_invoice_modal_options()
    else if isReceptionForm($form)
      options = reception_modal_options()
    else return Promise.reject("Modal type cannot be guessed!")
    E.ajax.html options
