AttributeError: 'BaseDocument' error after updating ERPNext

Hi, after updating we found this error:
AttributeError: ‘BaseDocument’ object has no attribute ‘against_sales_order’
Any ideas? Here is the complete log:

Executing erpnext.patches.v4_1.fix_jv_remarks in our-erp.com (erp4)
Traceback (most recent call last):
  File "/root/frappe-bench/env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.0.0', 'console_scripts', 'frappe')()
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 39, in main
    ret = run(fn, args)
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
    out = globals().get(fn)(**args)
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
    return fn(*args, **new_kwargs)
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 422, in latest
    frappe.modules.patch_handler.run_all()
  File "/root/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/root/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 50, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/root/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 66, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/root/frappe-bench/apps/erpnext/erpnext/patches/v4_1/fix_jv_remarks.py", line 13, in execute
    jv.create_remarks()
  File "/root/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_voucher/journal_voucher.py", line 237, in create_remarks
    if d.against_sales_order and d.credit:
AttributeError: 'BaseDocument' object has no attribute 'against_sales_order'

I forgot to mention that we see in the URL this message:
"Updating. We will be back in a few moments…
We did:

./scripts/update.sh
./env/bin/pip install babel
./env/bin/pip install pdfkit

did you migrate to the new bench?

No, we didnt. Thanks! We migrated with these instructions,as we had already version 4.0:

But after following them, we have three folders:
bench-repo frappe-bench frappe-bench-backup
And then the update is not working:

cd frappe-bench
./scripts/update.sh

As one of the instructions of the migration was

cd ~/frappe-bench
rm -rf install_scripts scripts templates standard_apps.json Readme.md .gitignore .git .update_bench

With the new bench the update command is bench update

Also, You might have to reload_doc when get the “no attribute” traceback

bench frappe --reload_doc accounts doctype journal_voucher

We tried bench update and also:
bench frappe --reload_doc accounts doctype journal_voucher
but still get the error:

Traceback (most recent call last):
  File "/root/frappe-bench/env/bin/frappe", line 9, in <module>
    load_entry_point('frappe==4.0.0', 'console_scripts', 'frappe')()
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 39, in main
    ret = run(fn, args)
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 83, in run
    out = globals().get(fn)(**args)
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 67, in new_fn
    return fn(*args, **new_kwargs)
  File "/root/frappe-bench/apps/frappe/frappe/cli.py", line 422, in latest
    frappe.modules.patch_handler.run_all()
  File "/root/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 25, in run_all
    if not run_single(patchmodule = patch):
  File "/root/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 50, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/root/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 66, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/root/frappe-bench/apps/erpnext/erpnext/patches/v4_1/fix_jv_remarks.py", line 13, in execute
    jv.create_remarks()
  File "/root/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_voucher/journal_voucher.py", line 237, in create_remarks
    if d.against_sales_order and d.credit:
AttributeError: 'BaseDocument' object has no attribute 'against_sales_order'
Error: None
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.1', 'console_scripts', 'bench')()
  File "/root/bench-repo/bench/cli.py", line 29, in cli
    return bench()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/root/bench-repo/bench/cli.py", line 130, in update
    patch_sites()
  File "/root/bench-repo/bench/utils.py", line 81, in patch_sites
    exec_cmd("{frappe} --latest all".format(frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites'))
  File "/root/bench-repo/bench/utils.py", line 59, in exec_cmd
    subprocess.check_call(cmd, cwd=cwd, shell=True)
  File "/usr/lib/python2.7/subprocess.py", line 511, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/root/frappe-bench/env/bin/frappe --latest all' returned non-zero exit status 1

Try bench frappe --reload_doc accounts doctype journal_voucher_detail

thanks it works, it is updating. But we are not able to login with the admin, it says invalid login…

You can reset the admin password with the command,
bench frappe --set_admin_password

Thank you, now we can access the updated version with the new bench.