From 5dcfdcb265a7217fd52ab5b7e3e51cc5c2430761 Mon Sep 17 00:00:00 2001
From: Goffin Simon <sig@odoo.com>
Date: Tue, 23 Feb 2021 12:05:25 +0000
Subject: [PATCH] [FIX] point_of_sale: Multicompany tax

Steps to reproduce the bug:

- Create a multi-company environment with two companies A & B
- Create two sales taxes TA & TB, one for company A & one for company B
- Created a shared product P and assign both TA & TB
- Create a fiscal position FP that maps TA and TB to other taxes
- Login with user having access of both companies
- Enable a POS session S with fiscal position and select FP
- Open S and select P as product

Bug:

A traceback was raised

PS: Only the taxes of company's user are loaded in taxes_by_id
So when trying to fetch taxes from a product with function get_taxes,
the taxes from other companies than company's user must be ignored.

opw:2448785

closes odoo/odoo#66684

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
---
 addons/point_of_sale/static/src/js/models.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index f6d0ee8eba0c..d9fc06b431f6 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -1788,7 +1788,9 @@ exports.Orderline = Backbone.Model.extend({
         var taxes_ids = this.get_product().taxes_id;
         var taxes = [];
         for (var i = 0; i < taxes_ids.length; i++) {
-            taxes.push(this.pos.taxes_by_id[taxes_ids[i]]);
+            if (this.pos.taxes_by_id[taxes_ids[i]]) {
+                taxes.push(this.pos.taxes_by_id[taxes_ids[i]]);
+            }
         }
         return taxes;
     },
-- 
GitLab