Skip to content
Snippets Groups Projects
Commit 93a767a6 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] pos_discount: error if misconfigured product

In case the discount product is misconfigured and therefore not loaded
by the POS, a traceback appears when applying a discount.

Add a comprehensive error message instead.

Closes #30574
opw-817527

closes odoo/odoo#30582
parent 5a6c523c
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,13 @@ msgstr ""
msgid "Discounts"
msgstr ""
#. module: pos_discount
#. openerp-web
#: code:addons/pos_discount/static/src/js/discount.js:28
#, python-format
msgid "No discount product found"
msgstr ""
#. module: pos_discount
#: model:ir.model.fields,field_description:pos_discount.field_pos_config_iface_discount
msgid "Order Discounts"
......@@ -55,6 +62,13 @@ msgstr ""
msgid "The default discount percentage"
msgstr ""
#. module: pos_discount
#. openerp-web
#: code:addons/pos_discount/static/src/js/discount.js:29
#, python-format
msgid "The discount product seems misconfigured. Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'."
msgstr ""
#. module: pos_discount
#: model:ir.model.fields,help:pos_discount.field_pos_config_discount_product_id
msgid "The product used to model the discount"
......
......@@ -23,6 +23,13 @@ var DiscountButton = screens.ActionButtonWidget.extend({
var order = this.pos.get_order();
var lines = order.get_orderlines();
var product = this.pos.db.get_product_by_id(this.pos.config.discount_product_id[0]);
if (product === undefined) {
this.gui.show_popup('error', {
title : _t("No discount product found"),
body : _t("The discount product seems misconfigured. Make sure it is flagged as 'Can be Sold' and 'Available in Point of Sale'."),
});
return;
}
// Remove existing discounts
var i = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment