Skip to Content
Menu
This question has been flagged
1 Reply
6170 Views

I'm changing odoo 10 module to odoo 11.I'm facing problem for missing dependency web.DataModel. How can I convert the following code to odoo 11 version?

          
var temp = {

       'partner_id': client['id'],
       'coupon_pos': cp.code,
          };
 new Model('partner.coupon.pos').call('update_history', 
 ['',temp]).done(function (result) {
     // alert("result")
     var applied = self.pos.applied_coupon;
     var already_used = false;
     for (var j in applied) {
     if (applied[j]['partner_id'][0] == client['id'] &&
         applied[j]['coupon_pos'] == order.coupon_status['code']) {
         applied[j]['number_pos'] += 1;
         already_used = true;
         break;
     }
   }
   if (!already_used) {
      var temp = {
          'partner_id': [client['id'], client['name']],
          'number_pos': 1,
          'coupon_pos': order.coupon_status['code']
       };
       self.pos.applied_coupon.push(temp);
    }
 });
self.gui.close_popup();


Avatar
Discard
Best Answer

Hi Jordan Web.DataModel is deprecated in odoo 11. so you can use RPC queries instead .

var rpc = require('web.rpc')

rpc.query(

     model: //your model,

     method: //your method,

      args: [{

          'arg1': value1,

      }]

 }).then(function (result) { 

            // your code 

  });

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 18
4627
0
Jan 19
2221
1
Jan 19
2792
1
Jan 19
1959
1
Dec 24
132