How to do it...

Most of the business logic of the Point of Sale application is written in JavaScript, so we just need to make changes to it to achieve the goal of this recipe. Add the following code to /static/src/js/pos_demo.js to show a warning when the user sells the product below the purchase price:

var screens = require('point_of_sale.screens');

screens.OrderWidget.include({
set_value: function (val) {
this._super(val);
var orderline = this.pos.get_order().get_selected_orderline();
var standard_price = orderline.product.standard_price;
if (orderline && standard_price) {
var line_price = orderline.get_base_price();
if (line_price < orderline.quantity * standard_price) {
this.gui.show_popup('alert', {
title: "Warning",
body: "Product price is set below product actual cost",
});
}
}
}
});

Update the pos_demo module to apply the changes. After the update, add the discount on the order line in such a way that the product price becomes less than the purchase price. A popup will appear with the following warning:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset