Skip to content

Commit

Permalink
[FIX] point_of_sale: list price display after tax mapping
Browse files Browse the repository at this point in the history
- In general settings:
    - Sales:
        - Activate discount
        - Activate Multiple Sale Prices with option computed from formula
    - Point of sale:
        - Activate Multiple Sale Prices with option computed from formula
    - Accounting:
        - Set show price tax-included
- Modify the Public Pricelist: Set to Global, price discount 50%
- Modify the sale tax to be included in price
- Create a 0% tax included in price
- Open fiscal position: Set auto-detect, replace sale 15% by 0%
- Open a product and set customer tax to sale 15%
- Open POS session configuration
    - Set fiscal position, tax included in price and public pricelist
- Add product "Pedal Bin"

You will see in strikethough text the original selling price with tax included,
while taxes should have been removed from the tax mapping.
Note that this is purely aesthetical, the total amount calculated is correct.
Fixing by calculating the price from the original selling price.

opw-2155779

closes #43284

X-original-commit: 7de221c
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
  • Loading branch information
agr-odoo committed Jan 14, 2020
1 parent d804720 commit 41be5fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
42 changes: 23 additions & 19 deletions addons/point_of_sale/static/src/js/models.js
Expand Up @@ -2040,6 +2040,28 @@ exports.Orderline = Backbone.Model.extend({
display_discount_policy: function(){
return this.order.pricelist.discount_policy;
},
compute_fixed_price: function (price) {
var order = this.order;
if(order.fiscal_position) {
var taxes = this.get_taxes();
var mapped_included_taxes = [];
var self = this;
_(taxes).each(function(tax) {
var line_taxes = self._map_tax_fiscal_position(tax);
if(tax.price_include && !_.contains(line_taxes, tax)){
mapped_included_taxes.push(tax);
}
});

if (mapped_included_taxes.length > 0) {
return this.compute_all(mapped_included_taxes, price, 1, order.pos.currency.rounding, true).total_excluded;
}
}
return price;
},
get_fixed_lst_price: function(){
return this.compute_fixed_price(this.get_lst_price());
},
get_lst_price: function(){
return this.product.lst_price;
},
Expand Down Expand Up @@ -2623,25 +2645,7 @@ exports.Order = Backbone.Model.extend({
},

fix_tax_included_price: function(line){
if(this.fiscal_position){
var unit_price = line.price;
var taxes = line.get_taxes();
var mapped_included_taxes = [];
_(taxes).each(function(tax) {
var line_taxes = line._map_tax_fiscal_position(tax);
if(tax.price_include && !_.contains(line_taxes, tax)){

mapped_included_taxes.push(tax);
}
});

if (mapped_included_taxes.length > 0) {
unit_price = line.compute_all(mapped_included_taxes, unit_price, 1, this.pos.currency.rounding, true).total_excluded;
}

line.set_unit_price(unit_price);
}

line.set_unit_price(line.compute_fixed_price(line.price));
},

add_product: function(product, options){
Expand Down
2 changes: 1 addition & 1 deletion addons/point_of_sale/static/src/xml/pos.xml
Expand Up @@ -1473,7 +1473,7 @@
<t t-if="line.display_discount_policy() == 'without_discount' &amp;&amp;
line.get_unit_display_price() != line.get_lst_price()">
<s>
<t t-esc="widget.format_currency(line.get_lst_price(),'Product Price')" />
<t t-esc="widget.format_currency(line.get_fixed_lst_price(),'Product Price')" />
</s>
<t t-esc="widget.format_currency(line.get_unit_display_price(),'Product Price')" />
</t>
Expand Down

0 comments on commit 41be5fb

Please sign in to comment.