From eb993b7f3bb93a951a63c5db73ca069ba8f835c3 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Fri, 11 Dec 2015 14:49:10 +0100 Subject: [PATCH] [FIX] purchase: supplier taxes in onchange_product_id When adding a line in a PO with the SUPERUSER_ID all the record rules didn't apply on him. Then all the supplier taxes set on the product were written in the PO line even if some of its were not in the company of the user. Then with the SUPERUSER_ID, just the company taxes of this user must be applied. Inspired from product_id_change in model 'sale.order.line'. opw:659236 --- addons/purchase/purchase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 8e7fff2a705..bcb9605239c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1253,7 +1253,11 @@ class purchase_order_line(osv.osv): else: price = product.standard_price - taxes = account_tax.browse(cr, uid, map(lambda x: x.id, product.supplier_taxes_id)) + if uid == SUPERUSER_ID: + company_id = self.pool['res.users'].browse(cr, uid, [uid]).company_id.id + taxes = product.supplier_taxes_id.filtered(lambda r: r.company_id.id == company_id) + else: + taxes = product.supplier_taxes_id fpos = fiscal_position_id and account_fiscal_position.browse(cr, uid, fiscal_position_id, context=context) or False taxes_ids = account_fiscal_position.map_tax(cr, uid, fpos, taxes) price = self.pool['account.tax']._fix_tax_included_price(cr, uid, price, product.supplier_taxes_id, taxes_ids)