Created
November 14, 2017 23:39
-
-
Save blaggacao/74e3c2915e44aa9cebaf66e55962bf0d to your computer and use it in GitHub Desktop.
pos fp fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
point_of_sale: [FIX] fp map to empty tax | |
Before this commit, `_map_tax_fiscal_position` could map to undifined, if the | |
target tax was empty (a valid use case, in other words: "remove"). | |
This commit filters or validates the mapping result in order to take care of the | |
undifined returns. As it is construed as a mapping function, we cannot take | |
care within the function itself but must handle it in downstream code. | |
Alternatively a wrapper could be made to encapuslate this safety check as well. | |
## To make a commit, type your commit message and press CTRL-ENTER. To cancel | |
## the commit, close the window. To sign off on the commit, press CTRL-S. | |
## | |
## You may also reference or close a GitHub issue with this commit. To do so, | |
## type `#` followed by the `tab` key. You will be shown a list of issues | |
## related to the current repo. You may also type `owner/repo#` plus the `tab` | |
## key to reference an issue in a different GitHub repo. | |
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js | |
index 3de8074..1450e83 100644 | |
--- a/addons/point_of_sale/static/src/js/models.js | |
+++ b/addons/point_of_sale/static/src/js/models.js | |
@@ -1575,7 +1575,7 @@ exports.Orderline = Backbone.Model.extend({ | |
return t.id === el; | |
})); | |
}); | |
- product_taxes = _.map(product_taxes, this._map_tax_fiscal_position.bind(this)); | |
+ product_taxes = _.map(product_taxes, this._map_tax_fiscal_position.bind(this)).filter(function(x){return x != undefined}); | |
var all_taxes = this.compute_all(product_taxes, price_unit, this.get_quantity(), this.pos.currency.rounding); | |
_(all_taxes.taxes).each(function(tax) { | |
@@ -2071,7 +2071,7 @@ exports.Order = Backbone.Model.extend({ | |
var mapped_included_taxes = []; | |
_(taxes).each(function(tax) { | |
var line_tax = line._map_tax_fiscal_position(tax); | |
- if(tax.price_include && tax.id != line_tax.id){ | |
+ if(line_tax && tax.price_include && tax.id != line_tax.id){ | |
mapped_included_taxes.push(tax); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment