Community mailing list archives

community@mail.odoo.com

Add new models to models.js

by
Same Motion S.A.C, Carlos Rodriguez
- 03/02/2016 11:44:27

Hello community,


How can I propperly extend the models.js of the Point Of Sale (v9) in order to add a new model?

Need to do it using another js (ie, mymodels.js) I have tried with the following code:


/*mymodels.js*/

odoo.define('point_of_sale_extension', function (require) {

"use strict";

var Model = require('web.DataModel');

var core = require('web.core');

var QWeb = core.qweb;

var _t = core._t;

var module = require('point_of_sale.DB');

var pos_model = require('point_of_sale.models');

var models = pos_model.PosModel.prototype.models;

var modscreen = require('point_of_sale.screens');


models.push ([

{

model: 'x_pos_promotions',

fields: ['x_name', 'x_promo_type', 'x_from_date', 'x_to_date', 'x_buy_qty', 'x_get_qty', 'x_discount', 'x_get_product'],

domain: null,

loaded: function(self, promotions){

module.add_promotions(promotions);

},

}, {

model: 'x_pos_promotions_line',

fields: ['x_buy_product','x_promotion_id'],

domain: null,

loaded: function(self, promotions_line){

module.add_promotions_line(promotions_line);

},

}

]);

)};


Best regards,

Carlos Rodríguez Rossi