agritheory / inventory_tools

A collection of features to streamline and enhance inventory management and manufacturing workflows in ERPNext.
https://agritheory.com/documentation/inventory_tools
Other
24 stars 13 forks source link

fix: make uom enforcement respond better to toggle on/off #33

Closed agritheory closed 1 year ago

agritheory commented 1 year ago

To test - load an unsaved purchase order (or any other doctype that's configured for OM enforcement) and then toggle it on and off while searching the UOM. Should defeat the following error:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1620, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/search.py", line 37, in search_link
    search_widget(
  File "apps/frappe/frappe/desk/search.py", line 108, in search_widget
    raise e
  File "apps/frappe/frappe/desk/search.py", line 85, in search_widget
    frappe.response["values"] = frappe.call(
  File "apps/frappe/frappe/__init__.py", line 1620, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/__init__.py", line 802, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/inventory_tools/inventory_tools/inventory_tools/overrides/uom.py", line 26, in uom_restricted_query
    return search_link(doctype, txt, searchfield, start, page_len, filters)
  File "apps/frappe/frappe/desk/search.py", line 37, in search_link
    search_widget(
  File "apps/frappe/frappe/desk/search.py", line 74, in search_widget
    sanitize_searchfield(searchfield)
  File "apps/frappe/frappe/desk/search.py", line 21, in sanitize_searchfield
    if SPECIAL_CHAR_PATTERN.search(searchfield):
TypeError: expected string or bytes-like object