Item Variants are synced with template when created in portal, but not through API

Hi all,
I have found a possible bug when trying to create Item Variants with API.

How to replicate the issue:

ERPNext portal:

  1. Create a new Item with a custom field, for the sake of example “types”. Fulfill it with some data.
  2. Check has_variants and add an Item Attribute.
  3. Add “card_types” field to Item Variant Settings to make sure that they will be synced with item variants.
  4. Create a few variants based on Item Attributes.
    Result: all created variants have field “card_types” populated as expected.


  1. Delete variants created in previous phase.
  2. Use frappeClient to instert new variants:
                        "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.