Odoo Help


How to Inherit POS javascript method from db.js?

Vinod Singh
on 10/13/15, 5:43 AM 1,137 views

I need to override a method from POS javascript file(db.js) search_product_in_category. I tried it using following code but no luck.

function pos_advance_search(instance, module){

var PosDBSuper = module.PosDB
module.PosDB = module.PosDB.include({
load_server_data: function(){
var self = this;
var loaded = PosDBSuper.prototype.load_server_data.call(this);
return loaded; 

search_product_in_category: function(category_id, query){

// some code goes here....

return res;


var _super = window.openerp.point_of_sale;
window.openerp.point_of_sale = function(instance){
var module = instance.point_of_sale;

pos_advance_search(instance, module);


Lithin T
On 10/13/15, 8:00 AM
openerp.YOUR_CUSTOM_MOUDLE_NAME = function (instance) {
var _t = instance.web._t;
var QWeb = instance.web.qweb;
var module = instance.point_of_sale;

init: function(options){
var self = this;

search_product_in_category: function(category_id, query){

//You can add your custom code here

try {
query = query.replace(/[\[\]\(\)\+\*\?\.\-\!\&\^\$\|\~\_\{\}\:\,\\\/]/g,'.');
query = query.replace(/ /g,'.+');
var re = RegExp("([0-9]+):.*?"+query,"gi");
return [];
var results = [];
for(var i = 0; i < this.limit; i++){
r = re.exec(this.category_search_string[category_id]);
var id = Number(r[1]);
return results;


Dear Vinod,
you can try the above method.

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/13/15, 5:43 AM
Seen: 1137 times
Last updated: 10/13/15, 8:00 AM