I’d like to expand the Frappe Item DocType so that I can have another table related to the Item DocType which is used to store more data about items.
I want to use a separate table so that the Item DocType table doesn’t end up too wide. I have a lot of items with various attributes that many of the Items might not have.
So, I’d like to create an “Item Attribute” DocType and a child table for Item to link the Items to their “Attributes".
The problem is that I still want them to be filterable in the Item Listview. That means I’d need to allow some method to JOIN the Item to its attributes.
I might be misunderstanding what you’re trying to do, but if this new attribute table is a child of the Item doctype, it’s already implicitly joined. You should be able to filter by child table fields right out of the box.
I have a Child Table DocType called ‘Item Attributes’. The Item DocType has that Child Table added via a field called ‘Item Item Attributes’
The ‘Item Attributes’ has a Link field called ‘Attribute’ and a Data field called ‘Attribute Value’.
So, for instance, I have an item called “Ford Model T”. In the Model T’s ‘Item Item Attribute’ child table there is a row with a “Curb Weight” Attribute with a value of 1200.
I’d like to be able to filter the Item DocType (in Listview) to find all of the Items with a Curb Weight == 1200, for example.
Yeah, the list view doesn’t allow for that kind of filtering, where the value of one field (Attribute) is being compared to the value of another field (Attribute Value).
A JOIN statement wouldn’t fix this issue, I don’t think. You might be able to do something with virtual fields, but last I checked virtual fields weren’t available to list view filters.
Basically using the default filters, I can filter by “Item Item Attributes” Attribute Value == 1200, however that will get any Item that has ANY of its attribute values of 1200 (not just the “curb weight”).
I would just add the “attributes” as columns to the Item DocType, but some Items might have 50 columns of attributes that aren’t relevant to the vast majority of other items, and thus I’d end up with a very wide tabItems table…
Yes, a simple join wouldn’t fix it. I’d need to modify listview.js to add more logic than that such that any of the Attribute Values are seen as “fields” that can be filtered by.