[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.

opw-817527
This commit is contained in:
Nicolas Martinelli
2018-02-22 11:01:40 +01:00
committed by Nicolas Martinelli
parent 310e3c15fd
commit 075f13ac63
2 changed files with 21 additions and 0 deletions
+14
View File
@@ -46,6 +46,13 @@ msgstr ""
msgid "Discount Product"
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"
@@ -56,6 +63,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;