Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is it possible to override only ONE model loader of addons/point_of_sale/static/src/js/models.js?

By
Pascal Tremblay
on 2/2/16, 9:16 AM 582 views

Hello all,

In the file odoo-8.0-20151203/openerp/addons/point_of_sale/static/src/js/models.js, there is this code :

module.PosModel = Backbone.Model.extend({
models: [
{
model: 'res.users',
fields: ['name','company_id'],
ids: function(self){ return [self.session.uid]; },
loaded: function(self,users){ self.user = users[0]; },
},{
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]; },
},{
model: 'decimal.precision',
fields: ['name','digits'],
loaded: function(self,dps){
self.dp = {};
for (var i = 0; i < dps.length; i++) {
self.dp[dps[i].name] = dps[i].digits;
}
},
..............................................


I only want to modify ONE model (res.company) in my own module. Is it possible?

Or do I have to override ALL models even if I want to modify only one of them?

Thanks to help


UPDATE #1

With this code, I think that I override ALL the original models with only this new one. So, it doesn't work.

openerp.canada_rounding = function (instance) {
var module=instance.point_of_sale
var round_pr = instance.web.round_precision
module.PosModel = module.PosModel.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]; },
}
]
});
}

0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 2/2/16, 11:08 AM

This post solves my problem : https://www.odoo.com/fr_FR/forum/help-1/question/inheritance-of-posmodel-in-pos-models-js-file-59023

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/2/16, 9:16 AM
Seen: 582 times
Last updated: 2/2/16, 11:08 AM