Hi!
I'm trying to add a product that is a welding fee to an order. The goal is to add this product automatically for customers when they add certain kind of product to their cart.
For now I created an automated action on update and I execute this python code (because I tried to create a new record and I can't get it to work).
welding_product = env['product.product'].search([('name', '=', 'Frais de soudure')], limit=1)
is_fee_added = env['sale.order.line'].search([('name', '=', 'Frais de soudure')], limit=1)
if welding_product and is_fee_added is None:
new_line = env['sale.order.line'].create({
'product_id': welding_product.id,
'name': welding_product.name,
'order_id': record.id,
'product_uom_qty': 1
})
new_line.product_id_change()
Here's my automated action.
Can you help me make it work? Thank you!