I have items that require variants and I have set up item attributes such as Color, Size, etc. However, a large portion of my inventory involves single items that don’t require variants. I would like the single items to also have attributes like Color and Size without the need for a variant. Is there a recommended way to customize the item form so it includes select fields that use the values contained in the existing item attributes?
@codeman In order to achieve what you want you will have to do the following:
- Create a new doctype
This doctype will be used as a child table later in the modified version of Item
doctype. You can call it Single Item Attributes
and it should be a way to link the Item
doctype with both Item Attribute
& Item Attribute Value
doctypes.
Or, you can use Item Variant
doctype instead of creating something like it.
- Customize
Item
doctype
You can add a section in order to separate your customization from main doctype fields. Then you can add the doctype you created in step 1 or Item Variant
doctype as a child table.
I hope that my explanation helps you.
@kid1194 Thanks so much for taking time to provide a solution! I followed your instructions using the Item Variant
doctype instead of creating something similar. The results are shown in the first image. The only issue I’m having is the Item Attribute Value
column doesn’t provide a drop-down like the ‘Item Attribute’ column. I had to manually type Red and New With Tags instead of selecting them from my predefined values. When I create a regular variant I usually see something like the second photo. Am I missing something?
The Item attributes are dynamic. They are based on on the Attributes defined in the template.
Meaning in the template you must define the Attributes. Based on the attributes in the template, values of the attributes are dynamically shown in the variant item.
In your case you do not have a Template item.
You cannot use the doctypes Attributes and Attributes values as it is.
You should define Attribute value field as Link of type Item Attribute Value to get the values.
You can write a custom script to restrict the values based on the Attribute. (note you will only get keys not the actual value. You should configure the Naming section in the Item Attribute value table)
//Filter Search results in Item Attribute Value based on Attribute
cur_frm.set_query("item_attribute_value_field", "new_attribute_table", function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
// Put your Logic to fetch the attribute
//values based on Attribute here ie filtered_values
return{
filters: [
['Item Attribute Value', 'new_attribute_tabble', '=', filtered_values],
]
};
}),
@codeman It is true, the attribute value is of type Data
in Item Variant
doctype…
So I guess that you should create your own table doctype…
-
Doctype
Create a new doctype using the following:-
Properties
- Name:
Custom Item Attribute
- Is Table:
true
- Name:
-
First Field
- Fieldname:
custom_attribute
- Fieldtype:
Link
- Label:
Custom Attribute
- Options:
Item Attribute
- Fieldname:
-
Second Field
- Fieldname:
custom_attribute_value
- Fieldtype:
Dynamic Link
- Label:
Custom Attribute Value
- Options:
custom_attribute
- Fetch From:
custom_attribute.item_attribute_values
- Fieldname:
-
-
Item Doctype
Modify theItem
doctype and add the following:-
First Field
- Fieldname:
custom_attributes_section
- Fieldtype:
Section Break
- Fieldname:
-
Second Field
- Fieldname:
custom_attributes
- Fieldtype:
Table
- Label:
Custom Attributes
- Options:
Custom Item Attribute
- Fieldname:
-
I hope that it works for you…