I get a studio automation on sale.order, which is below.
p6120 and p6121 are find but when trying to create the order line, Odoo can't do it because :
" (Enregistrement : product.product(6120,), Utilisateur : 2)"
What is the issue and the solution :-) ?
Thanks in advance
if not env.context.get('skip_auto_add_6120'):
try:
p6120 = env.ref('__custom__.6120')
except:
p6120 = None
try:
p6121 = env.ref('__custom__.6121')
except:
p6121 = None
# Si le produit cible (6120) n'existe pas on ne fait rien
if p6120:
ids_to_check = [p6120.id] + ([p6121.id] if p6121 else [])
# S'il n'y a aucune ligne avec 6120 ni 6121, on ajoute 6120
if not any(line.product_id.id in ids_to_check for line in record.order_line):
#raise UserError("La valeur de la variable est : %s" % p6120.id)
record.with_context(skip_auto_add_6120=True).order_line.create({
'order_id': record.id,
'product_id': p6120.id,
'product_uom_qty': 1,
'product_uom': p6120.uom_id.id,
'price_unit': p6120.list_price,
})