I need to extend part of point_of_sale js module (/point_of_sale/static/src/js/models.js) in odoo 10 in order to force it to load more fields from res.company model.
In base variant it looks like this:
odoo.define('point_of_sale.models', function (require) {
"use strict";
...
exports.PosModel = Backbone.Model.extend({
...
models: [
{
model: 'res.company',
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id', 'tax_calculation_rounding_method'],
ids: function(self){ return [self.user.company_id[0]]; },
loaded: function(self,companies){ self.company = companies[0]; },
}
]
})
})
While I need to add fields 'logo', 'city' the array fields.
I have tried lots of variants, the best result I got was with this solution:
odoo.define('my_module.models', function(require){
"use strict";
var core = require('web.core');
var modules = require('point_of_sale.models');
var _t = core._t;
modules.PosModel.include({
models: [
{
model: 'res.company',
fields: [ 'currency_id', 'email', 'website', 'company_registry', 'vat', 'name', 'phone', 'partner_id' , 'country_id', 'tax_calculation_rounding_method', 'logo', 'city'],
ids: function(self){ return [self.user.company_id[0]]; },
loaded: function(self,companies){ self.company = companies[0]; },
}
]
});
});
And everything I get for this is:
warning: Some modules could not be started
Missing dependencies: Array [ "point_of_sale.models" ]
Non loaded modules: Array [ "custom_receipt.models" ]
Debug: Object { custom_receipt.models: Object }
message in browser console. Can someone explain how to fix it, how to properly override JS in odoo 10 and why it doesn't see point_of_sale.models?
Did you get solution. I am facing same problem.