Help

2

How to add price validation in POS ,to pop up a warning when the price is less than the cost ?

Avatar
JC

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
3 Answers
3
Avatar
JC
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);
}

3 Comments
Avatar
Discard
Avatar
Atul Kumar jain
-

might be it's working

Avatar
Abhishek
-

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

Avatar
JC
-

No problem.

0
Avatar
Hamza Rana
Best Answer

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

Avatar
Discard
0
Avatar
ahmad
Best Answer

hi there.

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

;)

2 Comments
Avatar
Discard
Avatar
JC
-

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.

Avatar
ahmad
-

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