تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
9767 أدوات العرض

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 ?

الصورة الرمزية
إهمال
أفضل إجابة

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!

الصورة الرمزية
إهمال
الكاتب

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

الكاتب

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
Popup window in pos تم الحل
3
يوليو 25
17058
0
ديسمبر 18
2908
1
أكتوبر 18
6245
1
نوفمبر 24
1457
4
أكتوبر 24
3737