Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd

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!

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
apr. 24
1304
0
sep. 24
1382
0
mei 24
26
1
apr. 24
4787
0
mrt. 24
1692