简体   繁体   中英

web.DataModel is missing odoo11

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();

In v10 web.DataModel is used for calling py method in js but it is deprecated in odoo v11. If you want to call any py method in js file you need to use _rpc method. For example:

this._rpc({
                model: 'model.name',
                method: 'method_name',
                args: [arguments],
            })
            .then(function(result) {
                //custom code
            });

By this way you can convert v10 js code to v11.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM