Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9764 Lượt xem

0down votefavorite   
In my customization product price varies with respect to customer it works when add from products ,barcode , changing qty (numpad). After all orderlines are created if customer is change i want to reload all Lines


 var _super_orderline = models.Orderline;
 models.Orderline = models.Orderline.extend({
get_display_price: function(){    return custom_price;
}});


if order lines is created get_display_price , this doesn't work when changing customer ,


 save_changes: function(){    var self = this;
    var order = this.pos.get_order(); // got only client details }


How to reload orderlines when changing customer in POS ?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Silviaa,

To reload all of you order lines, you need to write your customize functionality,

i also faced this scenario, so i have created one for me,

Whenever you select a client  from client widget, and click on 'Change Customer' you have to call this customized method(under click event of '.next' button of ClientListScreenWidget).

this.$('.next').click(function(){ var order = self.pos.get_order();

   self.save_changes();

   self.refresh_orderlines(order); //CUSTOMIZED METHOD

   self.gui.back(); // FIXME HUH ?

  });


And here is the method:

refresh_orderlines: function(order){

    var lines = jQuery.extend(true, {}, order['orderlines']['models']);    

     //looping through each line  

    $.each(lines, function(k, line){

         var my_prod = line['product'];

         order.select_orderline(line); 

         //simulating product click event and create new duplicate order line

         if ($(".product[data-product-id='"+my_prod['id']+"']").length == 0){             order.pos.gui.screen_instances.products.click_product(my_prod);

         }

         else{

             $(".product[data-product-id='"+my_prod['id']+"']").trigger('click');

         }

         //removing original order line

         line.set_quantity('remove');

  });

  //saving new created lines

  order.trigger('change');

 },


Hope it helps!

Ảnh đại diện
Huỷ bỏ
Tác giả

Yes it reload and add new lines but not removing (i.e) when changing customer am getting 2 lines

Tác giả

I used to change quantity instead of triger product click

line.set_quantity(line['quantity']);

// $(".product[data-product-id='"+my_prod['id']+"']").trigger('click'); //line.set_quantity('remove');

Works for me. Thank you for idea

line.set_quantity('remove') should delete the current line for order, infact it totally depends on wat you exactly want to do... in my scenario i was to reset and recalculate many data, thats why i was creating new lines and removing old one.

You can go as per the one which suites you.

Thanks

Bài viết liên quan Trả lời Lượt xem Hoạt động
Popup window in pos Đã xử lý
3
thg 7 25
17057
0
thg 12 18
2905
1
thg 10 18
6245
1
thg 11 24
1456
4
thg 10 24
3736