Odoo Help

0

0
1 Antwoord
4
Avatar

Pawan India

--Pawan--

1597
| 4 4 8
Hyderabad, India
--Pawan--


Pawan India
21-02-17 01:35

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!

3 Opmerkingen
Silviaa India
23-02-17 02:36

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

Silviaa India
23-02-17 02:49

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

Pawan India
23-02-17 03:40

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

Stel een vraag
Schrijver
Blijf op de hoogte
1 volger(s)
Over deze community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now