From b4debf7e1b19710ef3dcc39448d08a698b5657b0 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 8 Nov 2017 19:47:32 -0800 Subject: [PATCH] [FIX] point_of_sale: take into account extra variant prices list_price is the base price of a product which does not include price_extra. Note that in the backend the pricelist computation uses product.price_compute('list_price') to compute the base price on which to apply the pricelist. For product.product this seems to be equivalent to the lst_price computed field. The original list_price field is unused but has not been removed to avoid breaking any 3rd party code that is using this field. opw-781629 --- addons/point_of_sale/static/src/js/models.js | 5 +++-- addons/point_of_sale/static/src/js/tests.js | 2 ++ addons/point_of_sale/tests/test_frontend.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 35fd4f52a74..adb4919f0e3 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -345,7 +345,8 @@ exports.PosModel = Backbone.Model.extend({ }, },{ model: 'product.product', - fields: ['display_name', 'list_price', 'standard_price', 'categ_id', 'pos_categ_id', 'taxes_id', + // todo remove list_price in master, it is unused + fields: ['display_name', 'list_price', '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'], order: _.map(['sequence','default_code','name'], function (name) { return {name: name}; }), @@ -1233,7 +1234,7 @@ exports.Product = Backbone.Model.extend({ (! item.date_end || moment(item.date_end).isSameOrAfter(date)); }); - var price = self.list_price; + var price = self.lst_price; _.find(pricelist_items, function (rule) { if (rule.min_quantity && quantity < rule.min_quantity) { return false; diff --git a/addons/point_of_sale/static/src/js/tests.js b/addons/point_of_sale/static/src/js/tests.js index 36fd7a49f8a..6c5c970f545 100644 --- a/addons/point_of_sale/static/src/js/tests.js +++ b/addons/point_of_sale/static/src/js/tests.js @@ -54,6 +54,7 @@ odoo.define('point_of_sale.tour.pricelist', function (require) { var product_limon = posmodel.db.search_product_in_category(0, 'Stringers')[0]; var product_pamplemousse = posmodel.db.search_product_in_category(0, 'Red grapefruit')[0]; var product_grapes = posmodel.db.search_product_in_category(0, 'Black Grapes')[0]; + var product_poire_conference = posmodel.db.search_product_in_category(0, 'Conference pears')[0]; var product_external_audit = posmodel.db.search_product_in_category(0, 'External Audit')[0]; var product_miscellaneous = posmodel.db.search_product_in_category(0, 'Miscellaneous')[0]; @@ -83,6 +84,7 @@ odoo.define('point_of_sale.tour.pricelist', function (require) { .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_papillon_orange, 'Pricelist base rounding', 1, undefined)) + .then(compare_backend_frontend(product_poire_conference, 'Public Pricelist', 1, undefined)) .then(function () { $('.pos').addClass('done-testing'); }); diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index c69381b0344..b3dae4e9350 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -36,6 +36,21 @@ class TestUi(odoo.tests.HttpCase): 'fields_id': field.id, 'value': 'account.account,' + str(account_receivable.id)}) + # test an extra price on an attribute + pear = env.ref('point_of_sale.poire_conference') + attribute_value = env['product.attribute.value'].create({ + 'name': 'add 2', + 'product_ids': [(6, 0, [pear.id])], + 'attribute_id': env['product.attribute'].create({ + 'name': 'add 2', + }).id, + }) + env['product.attribute.price'].create({ + 'product_tmpl_id': pear.product_tmpl_id.id, + 'price_extra': 2, + 'value_id': attribute_value.id, + }) + fixed_pricelist = env['product.pricelist'].create({ 'name': 'Fixed', 'item_ids': [(0, 0, {