From 3b02e3d63dcb62ed24cdbbdb7bd06f67849e1a24 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 25 Aug 2015 14:52:20 +0200 Subject: [PATCH] [FIX] sale*: company tax filtering f26b94f had as goal to filter the taxes of the product according to the company when the sale.order was created/edited as SUPERUSER_ID (Who ignores the record rules). Unfortunetaly, to filter the taxes, it used the company of the customer, while it's actually the company of the order which should be used. Indeed, for instance, partners can be shared among all companies. It was way less simple to access the company of the sale.order, this parameter being not available in the on_change method signature. This is the easiest way to solve this issue without breaking the API / retro-compatibility. opw-647819 --- addons/sale/sale.py | 7 ++++--- addons/sale/sale_view.xml | 11 ++++++----- addons/sale_stock/sale_stock_view.xml | 10 +++++----- addons/website_quote/controllers/main.py | 2 +- .../website_quote/views/website_quotation_backend.xml | 2 +- addons/website_sale/models/sale_order.py | 2 +- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index da75b51eba4..a0ccaf86361 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1078,7 +1078,7 @@ class sale_order_line(osv.osv): date_order=order['date_order'], fiscal_position=order['fiscal_position'][0] if order['fiscal_position'] else False, flag=False, # Force name update - context=context + context=dict(context, company_id=values.get('company_id')) )['value'] if defaults.get('tax_id'): defaults['tax_id'] = [[6, 0, defaults['tax_id']]] @@ -1134,8 +1134,9 @@ class sale_order_line(osv.osv): # The superuser is used by website_sale in order to create a sale order. We need to make # sure we only select the taxes related to the company of the partner. This should only # apply if the partner is linked to a company. - if uid == SUPERUSER_ID and partner.company_id: - taxes = product_obj.taxes_id.filtered(lambda r: r.company_id == partner.company_id) + if uid == SUPERUSER_ID and context.get('company_id'): + print 'company_id found', context['company_id'] + taxes = product_obj.taxes_id.filtered(lambda r: r.company_id.id == context['company_id']) else: taxes = product_obj.taxes_id result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes) diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 7a0925e990a..93df0e5f714 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -123,17 +123,17 @@