This question has been flagged
9 Replies
5987 Views

In brief I wish to find the following answers: 1) How to add cost price to POS local database ? 2) How to add a function to validate the selling price against the cost price in POS ?

I have look everywhere but can't find where to add the cost price in order to pass it down to local database when POS session is created. For POS session I guess changes should be made in models.js in static/src/js folder but I am not sure

Appreciate If someone could give me a light in this. I could not find any developer guide for POS. if there is any please send me the link . Thanks in advance.

Avatar
Discard
Author Best Answer


I have found the anwser
WHERE: addons/point_of_sale/static/src/js

WHAT: to add product cost to POS session
WHERE: models.js
HOW: look for product.product and add standard_price (in bold)
EXAMPLE:
return self.fetch(
'product.product',
[ 'standard_price' ,'name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13', 'default_code',
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description'],
[['sale_ok','=',true],['available_in_pos','=',true]],
{pricelist: self.get('shop').pricelist_id[0]} // context for price
);

WHAT: to display warning when selling price is less than cost
WHERE: In widgets.js
HOW: look for mode == 'price' add alert in the example below. (highlighted in bold)
EXAMPLE:
else if( mode === 'price'){

if (val < order.getSelectedLine().product.get('standard_price')){
alert( "Warning Price lower than cost");
}

order.getSelectedLine().set_unit_price(val);
}

Avatar
Discard

might be it's working

Thanks bro !!! Its helped me in some similar kind of need. Thanks again :-)

Author

No problem.

Best Answer

Try to follow the @JC example code on Odoo13, but not working.

odoo13/addons/point_of_sale/static/src/js/screen.js

else if( mode === 'price'){
var selected_orderline = order.get_selected_orderline();

    selected_orderline.price_manually_set = true;
  selected_orderline.set_unit_price(val);
if (val < order.get_selected_orderline().product.get('standard_price')){
  alert("Warning price lower than cost");
  }
  order.get_selected_orderline().set_unit_price(val);
}


any help would be very appreciated :)

Avatar
Discard
Best Answer

Hi, 
Can anyone help me with this exact question for Odoo 11?

Avatar
Discard
Best Answer

hi there.

is this code working? because i tried it already, and nothing pops up.

;)

Avatar
Discard
Author

The code is simple but only for experience users, try to troubleshoot yourself, for example place the alert somewhere else to display the value captured. test the condition by placing the alert inside and outside the condition.

thanks. i thought the code is for the pos backend, but it actually for the frontend pos.