Search code examples
odooodoo-14pos

Odoo-14: How to add orderline in current POS order


I need to append a "specific" product in current order's orderline on the the click on particular button, same functionality needs to be used i.e. when you click on any product and it gets added to orderline. With following line of code, unable to get order id:

this.env.pos.get_order()

I am unable to get in-process order id as it is not yet created in backend until its paid.


Solution

  • To get the order and add a new orderline you can use

    var order = this.env.pos.get_order();
    order.add_product(product, { quantity: 1, price: total_price });