2016-04-18 12 views
0

Ich schrieb ein benutzerdefiniertes Modul in Odoo und jetzt möchte ich einige Feldwerte aus dem benutzerdefinierten Modul in das POS-Widget importieren.Import Feld von benutzerdefinierten Modul in Odoo (V9) POS-Modul

Angenommen, ich habe ein Feld namens 'Rabatt' in einem Modul 'customer.discount'.

Wie lade ich die Feldwerte aus dem benutzerdefinierten Modul in das Widget für den POS? Das ist der .js-Code, den ich bisher habe. Irgendwelche Zeiger? Anmerkung: Dies ist für die neue Odoo API (V9).

odoo.define('pos_product_available.PosModel', function(require){ 
"use strict"; 


    var models = require('point_of_sale.models'); 
    var _super_posmodel = models.PosModel.prototype; 
    models.PosModel = models.PosModel.extend({ 
     initialize: function (session, attributes) { 
      var partner_model = _.find(this.models, function(model){ return model.model === 'product.product'; }); 
      partner_model.fields.push('qty_available'); 
      var customer_model = _.find(this.models, function(model){return 
       this.models.push({ 
          model: 'customer.discount', 
          fields: ['discount_price','percentage'], 
       }) 
      }), 
      return _super_posmodel.initialize.call(this, session, attributes); 
     }, 
    }) 
}) 

Antwort

0

Verwendung der Überschreibung der load_loaded der pos

models.load_loaded = function() {  
    model: 'my.model', 
    fields: ['id','name','image'], 
    domain: null, 
    loaded: function(self, params){ 
    // your code 
} } 
0
odoo.pos_custom = function(instance){ 
module = instance.point_of_sale; 
function pos_customer_discount(instance,module){ 
    var models = module.PosModel.prototype.models; 
    models.model.push({ 
     model: 'customer.discount', 
     fields: ['discount_price','percentage'], 
     loaded: function(self,customer_discount){self.customer_discount = customer_discount[0]; }, 
}); 
}