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

Point of sale

By
elalaoui
on 8/4/15, 7:53 AM 591 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"))

}

})()

0
tasnimabar
On 4/4/16, 6:52 AM

hello

i have the same problem and i search a solution 

Is that you find a solution ???

it's urgent 


0
Daniele Favara
On 1/5/16, 4:13 PM

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

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: 8/4/15, 7:53 AM
Seen: 591 times
Last updated: 4/4/16, 6:52 AM