Hi All,
Im trying to write an automation to generate an internal reference based on variant attributes.
I have created an automation to activate on creation, filtered to only act on products with attributes. Here is the code, it doesn't seem to work but I cant think of why, can anyone suggest something to try?
variant_values = [] for line in record.attribute_line_ids: for value in line.value_ids: variant_values.append(value.name) # Create the internal reference base_reference = record.default_code or "PROD" # This code will change, just a place holder for now to test
new_internal_ref = base_reference + "-" + "-".join(variant_values) # update the record record.write({'default_code': new_internal_ref})