تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7431 أدوات العرض

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){
res=[]

// some code goes here....

return res;

},
});
},

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

pos_advance_search(instance, module);

}
})()

الصورة الرمزية
إهمال
أفضل إجابة
openerp.YOUR_CUSTOM_MOUDLE_NAME = function (instance) {
var _t = instance.web._t;
var QWeb = instance.web.qweb;
var module = instance.point_of_sale;

module.PosDB.include({
init: function(options){
var self = this;
this._super();
},

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");
}catch(e){
return [];
}
var results = [];
for(var i = 0; i < this.limit; i++){
r = re.exec(this.category_search_string[category_id]);
if(r){
var id = Number(r[1]);
results.push(this.get_product_by_id(id));
}else{
break;
}
}
return results;
},
});


};

Dear Vinod,
you can try the above method.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
نوفمبر 22
3243
1
أكتوبر 22
6170
2
يوليو 22
20760
0
مارس 19
3740
1
يناير 25
2375