I set product.name to an entry already created using the client interface but I am still getting the same error: trytond.model.modelstorage.RequiredValidationError: A value is required for field “Product Template” in "Product Variant"
There is also an error: psycopg2.IntegrityError: null value in column “template” violates not-null constraint
Oups, I tought you where using the import/export feature but I realized that you are using proteus.
In proteus you should first create a template record and then create the variants related to it.
You can use the following snipped as reference:
Template = Model.get('product.tempate')
template = Template()
template.name = 'T-Shirt'
# set all the required fields ie:
template.unit = unit
# A product is automatically created as per default value
product, = template.products
product.code = '1234-W'
# Set whatever attributes you need
product.color = 'WHITE'
for color in colors:
product = template.products.new()
product.code = '1234-C'
product.color = color
# Save template and all the related products
template.save()
Thank you all for trying to help but using proteus requires a much deeper understanding of Tryton than I have. Unfortunately the client interface import is broken for Attributes which is what led me to try proteus.
Since there is no other way forward, I inserted the Attributes directly into the database.