Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
6983 Zobrazení


I'm trying to overwrite Orderline price in POS Odoo


**My price.js**


    get_unit_display_price: function(){    

        var self = this;           

        var line = self.export_as_JSON();
        var product = this.pos.db.get_product_by_id(line.product_id);     

        fields.product_id  = line.product_id;
        fields.pricelist_id   = this.pos.config.pricelist_id[0];
        fields.uom = product.uom_id;
        fields.line_qty = line.qty;
        fields.price_unit = line.price_unit;
        var model = new Model('pos.order');
         this.total_price = model.call('calculate_price',         

                  [0, fields]).done(function(result){       

              total_price = result['total_price'];
                     return  result['total_price'];
                });
             }


**price.xml**



            <t t-jquery=".price" t-operation="append">              

           <t t-esc="widget.format_currency(line.get_unit_display_price)"/>     

            </t>


I'm getting value **total_price** from Model (price.py)

But returning is **undefined** in get_unit_display_price in xml file.
How to set value in xml from js after execution of new model function (js value from model) ?.

Avatar
Zrušit
Nejlepší odpověď

If you want to return value in result['total_price'].
Frist create a var price_new in function get_unit_display_price.
Store result['total_price'] to price_new inside the python call function.

Return price_new after python call function.

Your code should look like:

    get_unit_display_price: function(){    

        var self = this;           

        var price_new;

        var line = self.export_as_JSON();
        var product = this.pos.db.get_product_by_id(line.product_id);     

        fields.product_id  = line.product_id;
        fields.pricelist_id   = this.pos.config.pricelist_id[0];
        fields.uom = product.uom_id;
        fields.line_qty = line.qty;
        fields.price_unit = line.price_unit;
        var model = new Model('pos.order');
         this.total_price = model.call('calculate_price',         

                  [0, fields]).done(function(result){       

                      total_price = result['total_price'];
                      price_new =  result['total_price'];
                });

                 return price_new
             }

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
lis 19
4652
0
čvn 18
3390
1
pro 17
4801
0
úno 17
3819
0
dub 25
1165