Issues with conditional statement in custom PO form

warehouse should be with company abbr eg: “Work In Progress - ABBR”

I just tried on my development setup, it works.

share your ui screenshot

I modified the code so that the abbreviation of the company was not inserted in the name of the warehouse to try to make it clearer. At the request of my boss.
Is it meaningful not to include the company’s abbreviation?

Exactly, what part of the UI do you want me to share?

Do you mean you modified Warehouse doctype, to save without abbr?
Without abbr warehouse name is invalid. it wont allow you to save anyways.

Share your page, where you r customization like item_type field, warehouse field etc are visible, with console

Exactly, and it has worked well so far.

This is the Doctype setting:




frappe.ui.form.on("Production Order", {
setup: function(frm) {
var item_group = "";

    if (frm.doc.item_type == "Compund") {
        item_group = "Compounds";
    } else
    if (frm.doc.item_type == "Raw material") {
        item_group = "Raw material";
    }

    frm.set_value({
      "wip_warehouse": "Work In Progress",
      "fg_warehouse": item_group
    });
	
	frm.set_query("production_item", function () {
		return {
			query: "erpnext.controllers.queries.item_query",
				filters: {
					'is_stock_item': 1,
					'item_group': item_group
				}
			}
	});
}

})

The above code works on my local machine. I added a field item_type

Thank you very much for your patience and your help @schilgod.
I am having many problems with my ERPNext and I need to do many things that until now are impossible for me to do because I only get errors.

And now, when a I click over the production_item field, I get this error:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/search.py", line 14, in search_link
    search_widget(doctype, txt, query, searchfield=searchfield, page_length=page_length, filters=filters)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/search.py", line 35, in search_widget
    searchfield, start, page_length, filters, as_dict=as_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/queries.py", line 178, in item_query
    fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/reportview.py", line 357, in get_filters_cond
    if isinstance(f[1], string_types) and f[1][0] == '!':
IndexError: string index out of range