diff options
| author | Antoine Prieels <anp@odoo.com> | 2020-06-12 09:08:49 +0000 |
|---|---|---|
| committer | Antoine Prieels <anp@odoo.com> | 2020-06-12 12:13:22 +0000 |
| commit | 1759a17c0ee3e0b1d943ac8316a1aac20ac5976c (patch) | |
| tree | a84bf4a06c1343d457d049bdb5382d388827b1be /addons | |
| parent | 2fc5180acf279ef189f522be23f1b78c8ab80506 (diff) | |
[IMP] point_of_sale: Hide tips and discount products
Hide the tips and discount products from the ProductScreen.
TaskID: 2276054
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/point_of_sale/data/point_of_sale_data.xml | 4 | ||||
| -rw-r--r-- | addons/point_of_sale/static/src/js/db.js | 44 | ||||
| -rw-r--r-- | addons/point_of_sale/static/src/js/models.js | 2 | ||||
| -rw-r--r-- | addons/point_of_sale/static/tests/tours/point_of_sale.js | 25 | ||||
| -rw-r--r-- | addons/point_of_sale/views/pos_config_view.xml | 4 | ||||
| -rw-r--r-- | addons/pos_discount/models/pos_config.py | 2 |
6 files changed, 28 insertions, 53 deletions
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 aaf8008c0a4..ea61776fb73 100644 --- a/addons/point_of_sale/data/point_of_sale_data.xml +++ b/addons/point_of_sale/data/point_of_sale_data.xml @@ -20,7 +20,7 @@ <field name="categ_id" ref="point_of_sale.product_category_pos"/> <field name="default_code">TIPS</field> <field name="weight">0.01</field> - <field name="available_in_pos" eval="True"/> + <field name="available_in_pos">False</field> <field name="taxes_id" eval="[(5,)]"/> </record> @@ -31,7 +31,7 @@ <record id="product_product_consumable" model="product.product"> <field name="name">Discount</field> - <field name="available_in_pos">True</field> + <field name="available_in_pos">False</field> <field name="standard_price">0.00</field> <field name="list_price">0.00</field> <field name="weight">0.00</field> diff --git a/addons/point_of_sale/static/src/js/db.js b/addons/point_of_sale/static/src/js/db.js index 31fea30b1d7..3a2907fd9fa 100644 --- a/addons/point_of_sale/static/src/js/db.js +++ b/addons/point_of_sale/static/src/js/db.js @@ -181,32 +181,34 @@ var PosDB = core.Class.extend({ for(var i = 0, len = products.length; i < len; i++){ var product = products[i]; if (product.id in this.product_by_id) continue; - var search_string = utils.unaccent(this._product_search_string(product)); - var categ_id = product.pos_categ_id ? product.pos_categ_id[0] : this.root_category_id; - product.product_tmpl_id = product.product_tmpl_id[0]; - if(!stored_categories[categ_id]){ - stored_categories[categ_id] = []; - } - stored_categories[categ_id].push(product.id); + if (product.available_in_pos){ + var search_string = utils.unaccent(this._product_search_string(product)); + var categ_id = product.pos_categ_id ? product.pos_categ_id[0] : this.root_category_id; + product.product_tmpl_id = product.product_tmpl_id[0]; + if(!stored_categories[categ_id]){ + stored_categories[categ_id] = []; + } + stored_categories[categ_id].push(product.id); - if(this.category_search_string[categ_id] === undefined){ - this.category_search_string[categ_id] = ''; - } - this.category_search_string[categ_id] += search_string; + if(this.category_search_string[categ_id] === undefined){ + this.category_search_string[categ_id] = ''; + } + this.category_search_string[categ_id] += search_string; - var ancestors = this.get_category_ancestors_ids(categ_id) || []; + var ancestors = this.get_category_ancestors_ids(categ_id) || []; - for(var j = 0, jlen = ancestors.length; j < jlen; j++){ - var ancestor = ancestors[j]; - if(! stored_categories[ancestor]){ - stored_categories[ancestor] = []; - } - stored_categories[ancestor].push(product.id); + for(var j = 0, jlen = ancestors.length; j < jlen; j++){ + var ancestor = ancestors[j]; + if(! stored_categories[ancestor]){ + stored_categories[ancestor] = []; + } + stored_categories[ancestor].push(product.id); - if( this.category_search_string[ancestor] === undefined){ - this.category_search_string[ancestor] = ''; + if( this.category_search_string[ancestor] === undefined){ + this.category_search_string[ancestor] = ''; + } + this.category_search_string[ancestor] += search_string; } - this.category_search_string[ancestor] += search_string; } this.product_by_id[product.id] = product; if(product.barcode){ diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 459ac9138d5..ffb9d362016 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -400,7 +400,7 @@ exports.PosModel = Backbone.Model.extend({ model: 'product.product', fields: ['display_name', 'lst_price', 'standard_price', 'categ_id', 'pos_categ_id', 'taxes_id', 'barcode', 'default_code', 'to_weight', 'uom_id', 'description_sale', 'description', - 'product_tmpl_id','tracking', 'write_date'], + 'product_tmpl_id','tracking', 'write_date', 'available_in_pos'], order: _.map(['sequence','default_code','name'], function (name) { return {name: name}; }), domain: function(self){ var domain = ['&', '&', ['sale_ok','=',true],['available_in_pos','=',true],'|',['company_id','=',self.config.company_id[0]],['company_id','=',false]]; 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 72759fac829..b32537cc76f 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,6 @@ 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, 'Discount')[0]; compare_backend_frontend(product_letter_tray, 'Public Pricelist', 0, undefined)() .then(compare_backend_frontend(product_letter_tray, 'Public Pricelist', 1, undefined)) @@ -76,9 +75,6 @@ odoo.define('point_of_sale.tour.pricelist', function (require) { .then(compare_backend_frontend(product_letter_tray, 'Category', 1, undefined)) .then(compare_backend_frontend(product_wall_shelf, 'Product template', 1, undefined)) .then(compare_backend_frontend(product_wall_shelf, 'Dates', 1, undefined)) - .then(compare_backend_frontend(product_miscellaneous, 'Cost base', 1, undefined)) - .then(compare_backend_frontend(product_miscellaneous, 'Pricelist base', 1, undefined)) - .then(compare_backend_frontend(product_miscellaneous, 'Pricelist base 2', 1, undefined)) .then(compare_backend_frontend(product_small_shelf, 'Pricelist base rounding', 1, undefined)) .then(compare_backend_frontend(product_whiteboard, 'Public Pricelist', 1, undefined)) .then(function () { @@ -106,10 +102,6 @@ odoo.define('point_of_sale.tour.pricelist', function (require) { content: "select fixed pricelist", trigger: ".selection-item:contains('Fixed')", }, { - content: "prices should be updated in the product screen", - trigger: ".product:contains('Discount'):contains('$ 1.00')", - run: function () {}, // it's a check - }, { content: "open customer list", trigger: "button.set-customer", }, { @@ -129,10 +121,6 @@ odoo.define('point_of_sale.tour.pricelist', function (require) { content: "cancel pricelist dialog", trigger: ".button.cancel:visible", }, { - content: "prices should be updated in the product screen", - trigger: ".product:contains('Discount'):contains('$ 0.00')", - run: function () {}, // it's a check - }, { content: "open customer list", trigger: "button.set-customer", }, { @@ -195,19 +183,6 @@ shelf have not (their price was manually overridden)", content: "select fixed pricelist", trigger: ".selection-item:contains('min_quantity ordering')", }, { - content: "order 1 miscellaneous product", - trigger: ".product:contains('Discount')", - }, { - content: "order 1 miscellaneous product", - trigger: ".product:contains('Discount')", - }, { - content: "order 1 miscellaneous product", - trigger: ".product:contains('Discount')", - }, { - content: "verify there is one line with 3 miscellaneous products", - trigger: ".orderline:contains('Discount') em:contains('3.000')", - run: function () {}, // it's a check - }, { content: "close the Point of Sale frontend", trigger: ".header-button", }, { diff --git a/addons/point_of_sale/views/pos_config_view.xml b/addons/point_of_sale/views/pos_config_view.xml index 232c00ff0be..72ef20b27d7 100644 --- a/addons/point_of_sale/views/pos_config_view.xml +++ b/addons/point_of_sale/views/pos_config_view.xml @@ -398,9 +398,7 @@ <div class="content-group" attrs="{'invisible': [('iface_tipproduct', '=', False)]}"> <div class="mt16"> <label string="Tip Product" for="tip_product_id" class="o_light_label"/> - <field name="tip_product_id" - domain="[('available_in_pos', '=', True)]" - context="{'default_available_in_pos': True}"/> + <field name="tip_product_id"/> </div> </div> </div> diff --git a/addons/pos_discount/models/pos_config.py b/addons/pos_discount/models/pos_config.py index 936aa7aa04d..cc7334a702e 100644 --- a/addons/pos_discount/models/pos_config.py +++ b/addons/pos_discount/models/pos_config.py @@ -10,7 +10,7 @@ class PosConfig(models.Model): 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', 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.') + domain="[('sale_ok', '=', True)]", help='The product used to model the discount.') @api.onchange('company_id','module_pos_discount') def _default_discount_product_id(self): |
