Community mailing list archives

Re: Add new models to models.js

- 03/02/2016 22:11:37
Hi carlos,
 If you have read the 'model.js' of Odoo9 POS, its mentioned there as commented.

line no:991-1031

// Loads openerp models at the point of sale startup.
// load_models take an array of model loader declarations.
// - The models will be loaded in the array order.
// - If no openerp model name is provided, no server data
// will be loaded, but the system can be used to preprocess
// data before load.
// - loader arguments can be functions that return a dynamic
// value. The function takes the PosModel as the first argument
// and a temporary object that is shared by all models, and can
// be used to store transient information between model loads.
// - There is no dependency management. The models must be loaded
// in the right order. Newly added models are loaded at the end
// but the after / before options can be used to load directly
// before / after another model.
// models: [{
// model: [string] the name of the openerp model to load.
// label: [string] The label displayed during load.
// fields: [[string]|function] the list of fields to be loaded.
// Empty Array / Null loads all fields.
// order: [[string]|function] the models will be ordered by
// the provided fields
// domain: [domain|function] the domain that determines what
// models need to be loaded. Null loads everything
// ids: [[id]|function] the id list of the models that must
// be loaded. Overrides domain.
// context: [Dict|function] the openerp context for the model read
// condition: [function] do not load the models if it evaluates to
// false.
// loaded: [function(self,model)] this function is called once the
// models have been loaded, with the data as second argument
// if the function returns a deferred, the next model will
// wait until it resolves before loading.
// }]
// options:
// before: [string] The model will be loaded before the named models
// (applies to both model name and label)
// after: [string] The model will be loaded after the (last loaded)
// named model. (applies to both model name and label)

On Wed, Mar 2, 2016 at 10:17 PM, Carlos Rodríguez <> wrote:

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:


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){



}, {

model: 'x_pos_promotions_line',

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

domain: null,

loaded: function(self, promotions_line){






Best regards,

Carlos Rodríguez Rossi

Post to:

Cybrosys Odoo Department
 +91 494 3015006 / 07
 +91 8606827707
Facebook Twitter LinkedIn Google Plus Pinterest Company
This email and any file transmitted with it are confidential and intended solely for the use of the individual or entity whom they are addressed.If you have received this email in errort please notify the system manager. The company accepts no liability for any damage caused by any virus transmitted by this email.