At “Quotation” I placed a “Select” custom field named “Item Group” including only a couple of item groups. What I want is that the user can only select items (obviously at items table) that belong to the item group selected.
I tried addapting codes like these:
But just can’t make it work.
Also… I found that it’s not possible to unset as “Reading Only” the field “item group” at “Quotation Item” doctype. (I’m using Frappe Cloud).
Where it says “doc.item_group” I made the assumption that your select field has the name “item_group”. You should change it to the actual name of your select field.
cur_frm.fields_dict[‘items’].grid.get_field(‘item_code’) - points to the name of the table and then the fieldname on the current document that should pop up the filtered list
‘Item’, ‘item_group’, ‘=’, doc.tipo_de_orden - this gets a DIFFERENT doctype, and the fieldname and then compares it to a field on your current document and then returns only the matches.
By default, it’s the “item_code” field in the “Quotation Item” doctype that is linked to the “Item” doctype. So you want to filter that linked list. You would only change this if you added a different link field to the “Quotation Item” doctype.
@Dbone I tried your code on “Taxes and Charges” table and it works.
Maybe shouldn’t be as ‘Read Only’ the 'item_group" at “Quotation Item” so it could have effect on filter. I will try adding a new field at ‘Item’ and same at “Quotation Item”.
But the idea to have two fields for the same purpose… aaarg. Should be easier, more simple!
I think you are not able to change query for Customer, because there exists query for Customer in ERPNext code and your custom query doesn’t work. Please check it