[FIX] pos_restaurant: order reminder with product without category

Sometimes, it is possible to have a product for which its category is
unknown by the pos db of the config. This can happen for example when
using pos_loyalty. If a user makes a "buy x get y" program with the
reward being a product with a category not accepted by the config
(e.g. due to a restrict category of the config), the category id cannot
be found in the db of this pos. This leads to problem in pos_restaurant
as under the button order, there is a reminder of the products that
should be sent either to the preparation display or the preparation
printer linked to this pos. If this preparation display or preparation
printer contains the category of the reward, the problem happens.

The fix is to not show the new category (as it is at first not available
due to the restrict so we comply with the choice of the user).
This might be a temporarly fix while waiting for a better solution.

closes odoo/odoo#131379

X-original-commit: a82b550dcf4311ee35570f5b9dc37bf50a46c17d
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Adrien Guilliams (adgu)
2023-08-17 13:03:05 +02:00
parent 0c4a94e17d
commit 1e4dbaa8bc
@@ -51,7 +51,7 @@ patch(ActionpadWidget.prototype, {
for (const idx in orderChange) {
const orderline = orderChange[idx];
const categoryId = this.pos.db.get_product_by_id(orderline.product_id).pos_categ_ids[0];
if (!categoryId) {
if (!categoryId || !this.pos.db.category_by_id[categoryId]) {
continue;
}
const category = this.pos.db.category_by_id[categoryId].name;