Skip to Content
Menu
This question has been flagged
2 Replies
2911 Views

hello everyone,

I want to display the internal spaces and the stock of each product, I do not know how to link the product with domestic locations

this is the code of my pos.js:


function pos_product_available(instance, module){

var PosModelSuper = module.PosModel

module.PosModel.prototype.models.push(

{model:'stock.location',

fields:[],

domain:function(self){return [['usage','=','internal']];},

loaded:function(self,locations){

self.locations=locations;

console.log(locations);

}

}

);

module.PosModel = module.PosModel.extend({

initialize:function(){

module.PosModel.__super__.initialize.apply(this,arguments);

this.locations=[]

},

load_server_data: function(){

var self = this;

var loaded = PosModelSuper.prototype.load_server_data.call(this);

loaded = loaded.then(function(){

return self.fetch(

'product.product',

['qty_available','location_id'],

[['sale_ok','=',true],['available_in_pos','=',true]],

{}

);

}).then(function(products){

$.each(products, function(){

$.extend(self.db.get_product_by_id(this.id) || {}, this)

});

return $.when()

})

return loaded;

},

refresh_qty_available:function(product){

var $elem = $("[data-product-id='"+product.id+"'] .qty-tag");

$elem.html(product.qty_available)

if (product.qty_available <= 0 && !$elem.hasClass('not-available')){

$elem.addClass('not-available')

}

},

push_order: function(order){

var self = this;

var pushed = PosModelSuper.prototype.push_order.call(this, order);

if (order){

order.get('orderLines').each(function(line){

var product = line.get_product();

product.qty_available -= line.get_quantity();

self.refresh_qty_available(product);

})

}

return pushed;

}

})

}

(function(){

var _super = window.openerp.point_of_sale;

window.openerp.point_of_sale = function(instance){

_super(instance);

var module = instance.point_of_sale;

pos_product_available(instance, module);

$('<link rel="stylesheet" href="/pos_product_available/static/src/css/pos.css"/>').appendTo($("head"))

}

})()

Avatar
Discard
Best Answer

hello

i have the same problem and i search a solution 

Is that you find a solution ???

it's urgent 


Avatar
Discard
Best Answer

It would help if you could use code style for your code

Avatar
Discard
Related Posts Replies Views Activity
0
Aug 23
1248
1
Jun 15
9718
1
Apr 24
1018
1
Nov 21
5939
0
Jul 21
312