From 41ea6e7ccd1d0877d3cfa3c389950a44c581aa85 Mon Sep 17 00:00:00 2001 From: Xavier ALT Date: Wed, 27 Feb 2013 11:45:05 +0100 Subject: [PATCH] [TEST] add unit test to ensure POS only considere product taxes from current session's company bzr revid: xal@openerp.com-20130227104505-9ndnub6zs8sjfhzj --- addons/point_of_sale/point_of_sale.py | 3 +-- .../point_of_sale/test/01_order_to_payment.yml | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index a4f2b3485bb..792b24b5dfe 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -1121,8 +1121,7 @@ class pos_order_line(osv.osv): account_tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids, context=context): - taxes_ids = filter(lambda t: t.company_id.id == line.order_id.company_id.id, line.product_id.taxes_id) - price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) + taxes_ids = [ tax for tax in line.product_id.taxes_id if tax.company_id.id == line.order_id.company_id.id ] price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) taxes = account_tax_obj.compute_all(cr, uid, taxes_ids, price, line.qty, product=line.product_id, partner=line.order_id.partner_id or False) diff --git a/addons/point_of_sale/test/01_order_to_payment.yml b/addons/point_of_sale/test/01_order_to_payment.yml index 9534e79095f..bf201affc4a 100644 --- a/addons/point_of_sale/test/01_order_to_payment.yml +++ b/addons/point_of_sale/test/01_order_to_payment.yml @@ -27,10 +27,23 @@ account_collected_id: account.iva price_include: 0 - - I assign this 5 percent tax on the PCSC349 product as a sale tax + I will create a second VAT tax of 5% but this time for a child company, to + ensure that only product taxes of the current session's company are considered + (this tax should be ignore when computing order's taxes in following tests) +- + !record {model: account.tax, id: account_tax_05_incl_chicago}: + name: VAT 05 perc Excl (US) + type: percent + amount: 0.05 + account_paid_id: account.iva + account_collected_id: account.iva + price_include: 0 + company_id: stock.res_company_1 +- + I assign those 5 percent taxes on the PCSC349 product as a sale taxes - !record {model: product.product, id: product.product_product_4}: - taxes_id: [account_tax_05_incl] + taxes_id: [account_tax_05_incl, account_tax_05_incl_chicago] - I create a new session -