diff --git a/addons/point_of_sale/data/point_of_sale_data.xml b/addons/point_of_sale/data/point_of_sale_data.xml
index 58a70c4cc87..aaf8008c0a4 100644
--- a/addons/point_of_sale/data/point_of_sale_data.xml
+++ b/addons/point_of_sale/data/point_of_sale_data.xml
@@ -30,17 +30,17 @@
- Miscellaneous
+ Discount
True
- 13.0
- 18.0
- 0.01
+ 0.00
+ 0.00
+ 0.00
consu
- MISC
-
+ DISC
+ False
diff --git a/addons/point_of_sale/static/img/product_product_49-image.jpg b/addons/point_of_sale/static/img/product_product_49-image.jpg
deleted file mode 100644
index 5aa7c3278bb..00000000000
Binary files a/addons/point_of_sale/static/img/product_product_49-image.jpg and /dev/null differ
diff --git a/addons/point_of_sale/static/tests/tours/point_of_sale.js b/addons/point_of_sale/static/tests/tours/point_of_sale.js
index 4f0a774ff09..77890a56b5a 100644
--- a/addons/point_of_sale/static/tests/tours/point_of_sale.js
+++ b/addons/point_of_sale/static/tests/tours/point_of_sale.js
@@ -55,7 +55,7 @@ odoo.define('point_of_sale.tour.pricelist', function (require) {
var product_desk_pad = posmodel.db.search_product_in_category(0, 'Desk Pad')[0];
var product_letter_tray = posmodel.db.search_product_in_category(0, 'Letter Tray')[0];
var product_whiteboard = posmodel.db.search_product_in_category(0, 'Whiteboard')[0];
- var product_miscellaneous = posmodel.db.search_product_in_category(0, 'Miscellaneous')[0];
+ var product_miscellaneous = posmodel.db.search_product_in_category(0, 'Discount')[0];
compare_backend_frontend(product_letter_tray, 'Public Pricelist', 0, undefined)()
.then(compare_backend_frontend(product_letter_tray, 'Public Pricelist', 1, undefined))
@@ -107,7 +107,7 @@ odoo.define('point_of_sale.tour.pricelist', function (require) {
trigger: ".selection-item:contains('Fixed')",
}, {
content: "prices should be updated in the product screen",
- trigger: ".product:contains('Miscellaneous'):contains('$ 1.00')",
+ trigger: ".product:contains('Discount'):contains('$ 1.00')",
run: function () {}, // it's a check
}, {
content: "open customer list",
@@ -130,7 +130,7 @@ odoo.define('point_of_sale.tour.pricelist', function (require) {
trigger: ".button.cancel:visible",
}, {
content: "prices should be updated in the product screen",
- trigger: ".product:contains('Miscellaneous'):contains('$ 18.00')",
+ trigger: ".product:contains('Discount'):contains('$ 0.00')",
run: function () {}, // it's a check
}, {
content: "open customer list",
@@ -196,16 +196,16 @@ shelf have not (their price was manually overridden)",
trigger: ".selection-item:contains('min_quantity ordering')",
}, {
content: "order 1 miscellaneous product",
- trigger: ".product:contains('Miscellaneous')",
+ trigger: ".product:contains('Discount')",
}, {
content: "order 1 miscellaneous product",
- trigger: ".product:contains('Miscellaneous')",
+ trigger: ".product:contains('Discount')",
}, {
content: "order 1 miscellaneous product",
- trigger: ".product:contains('Miscellaneous')",
+ trigger: ".product:contains('Discount')",
}, {
content: "verify there is one line with 3 miscellaneous products",
- trigger: ".orderline:contains('Miscellaneous') em:contains('3.000')",
+ trigger: ".orderline:contains('Discount') em:contains('3.000')",
run: function () {}, // it's a check
}, {
content: "close the Point of Sale frontend",
diff --git a/addons/pos_discount/models/pos_config.py b/addons/pos_discount/models/pos_config.py
index 46272218f67..0bc2d846a43 100644
--- a/addons/pos_discount/models/pos_config.py
+++ b/addons/pos_discount/models/pos_config.py
@@ -8,18 +8,17 @@ class PosConfig(models.Model):
_inherit = 'pos.config'
iface_discount = fields.Boolean(string='Order Discounts', help='Allow the cashier to give discounts on the whole order.')
- discount_pc = fields.Float(string='Discount Percentage', help='The default discount percentage')
+ discount_pc = fields.Float(string='Discount Percentage', help='The default discount percentage', default=10.0)
discount_product_id = fields.Many2one('product.product', string='Discount Product',
domain="[('available_in_pos', '=', True), ('sale_ok', '=', True)]", help='The product used to model the discount.')
- @api.onchange('module_pos_discount')
- def _onchange_module_pos_discount(self):
- if self.module_pos_discount:
- self.discount_product_id = self.env.ref('point_of_sale.product_product_consumable', raise_if_not_found=False)
- if not self.discount_product_id or not self.discount_product_id.available_in_pos or not self.discount_product_id.sale_ok:
- domain = [('available_in_pos', '=', True), ('sale_ok', '=', True)]
- self.discount_product_id = self.env['product.product'].search(domain, limit=1)
- self.discount_pc = 10.0
- else:
- self.discount_product_id = False
- self.discount_pc = 0.0
+ @api.onchange('company_id','module_pos_discount')
+ def _default_discount_product_id(self):
+ product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False)
+ self.discount_product_id = product if self.module_pos_discount and product and (not product.company_id or product.company_id == self.company_id) else False
+
+ @api.model
+ def _default_discount_value_on_module_install(self):
+ configs = self.env['pos.config'].search([])
+ for conf in configs:
+ conf._default_discount_product_id()
diff --git a/addons/pos_discount/views/pos_discount_views.xml b/addons/pos_discount/views/pos_discount_views.xml
index 7f7cc0c2dd9..0e38b16af64 100644
--- a/addons/pos_discount/views/pos_discount_views.xml
+++ b/addons/pos_discount/views/pos_discount_views.xml
@@ -17,4 +17,8 @@
+
+
+
+