Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odoo PoS get orderline product

I'm updating the update_payment_summary function in the Point_Of_Sale, this function is part of the PaymentScreenWidget. Now I'd like to retrieve the products from the orderlines.

I tried with

var order = this.pos.get('selectedOrder');
var orderlines = order.get('orderLines').models;

But when I print orderlines I get [object Object]

Any ideas how I can get the product object of every orderline?

like image 299
Jesse Avatar asked Dec 03 '25 17:12

Jesse


1 Answers

Yes there is a reason why it shows object.

OrderlineCollection definition.

module.OrderlineCollection = Backbone.Collection.extend({
        model: module.Orderline,
});

Orderline definition in Order Model.

orderLines:     new module.OrderlineCollection()

So if you observe above code it shows that orderline is an object of OrderlineCollection model and while you get orderlines from order model it will gives you an object of OrderlineCollection.

In order to identify what's there inside object you can iterate through it or you may print key-value from that object.

alert(orderline.forEach(function(k,v){k + " => + v}));

Or you can loop through the orderlines.

for (line in orderline){
    alert(line.product_id);
}
like image 72
Emipro Technologies Pvt. Ltd. Avatar answered Dec 06 '25 07:12

Emipro Technologies Pvt. Ltd.