Patch Issue: AttributeError: 'DeliveryNote' object has no attribute 'is_return'

Hi good day :slight_smile:
I need to go forward to upgrade from v13 to v14 but I still have 1 patch that was not yet resolved during v13 upgrade. Anyone can help me please :slight_smile:

I am having error in this patch: erpnext.patches.v12_0.set_purchase_receipt_delivery_note_detail
Error Message:

Executing erpnext.patches.v12_0.set_purchase_receipt_delivery_note_detail in [site] (_0f663089722405bc)
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 104, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 19, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 27, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 306, in migrate
    migrate(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 67, in migrate
    frappe.modules.patch_handler.run_all(skip_failing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 41, in run_all
    run_patch(patch)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 30, in run_patch
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 71, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 91, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v12_0/set_purchase_receipt_delivery_note_detail.py", line 94, in execute
    set_document_detail_in_return_document("Delivery Note")
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v12_0/set_purchase_receipt_delivery_note_detail.py", line 74, in set_document_detail_in_return_document
    doc_items = frappe.get_cached_doc(doctype, docname).get("items")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 834, in get_cached_doc
    doc = get_doc(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 877, in get_doc
    doc = frappe.model.document.get_doc(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 75, in get_doc
    return controller(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/delivery_note/delivery_note.py", line 57, in __init__
    if cint(self.is_return):
AttributeError: 'DeliveryNote' object has no attribute 'is_return'

I tried bench console
frappe.reload_doctype(‘Delivery Note’)
frappe.db.commit()

But still with same error message :frowning:

Use command bench --site sitename migrate --skip-failing

Hi @mohsininspire, thank you for your reply. I don’t want to skip this error. I need to fix it to proceed with v14.

bench --site sitename migrate --skip-failing

Then after use below command
bench --site sitename migrate

Hi @mohsininspire, same error message

Need to manual debug, it is in python memory but not yet in database:
image

Solution:
Delivery Note PY File line 57:
From → if cint(self.is_return):
Change to → if cint(self.get(‘is_return’)):

Then run bench migrate again

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.