Hi all,
I have found a possible bug when trying to create Item Variants with API.
How to replicate the issue:
ERPNext portal:
- Create a new Item with a custom field, for the sake of example “types”. Fulfill it with some data.
- Check has_variants and add an Item Attribute.
- Add “card_types” field to Item Variant Settings to make sure that they will be synced with item variants.
- Create a few variants based on Item Attributes.
Result: all created variants have field “card_types” populated as expected.
API:
- Delete variants created in previous phase.
- Use frappeClient to instert new variants:
client.insert({
"doctype": "Item",
"item_code": <data>,
"name": <data>,
"item_name": <data>,
"item_group": <data>,
"stock_uom": <data>,
"has_variants": 0,
'variant_of': <YOUR ITEM>,
"variant_based_on": 'Item Attribute',
"attributes": [{"YOUR ATTRIBUTE NAME": "YOUR ATTRIBUTE VALUE"}],
})
Result: created item variants do not have updated field “types” from the Item template.
Isn’t this a bug? If not, how to update all the fields from Item Variant Settings through API?
Btw, when you change something in synced fields in the item template and save it, the changes are propagated to item variants created through API, so sync works, but not during creation.