[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
This commit is contained in:
Goffin Simon 2015-12-11 14:49:10 +01:00
parent 80b373f1e5
commit eb993b7f3b
1 changed files with 5 additions and 1 deletions

View File

@ -1253,7 +1253,11 @@ class purchase_order_line(osv.osv):
else: else:
price = product.standard_price 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 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) 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) price = self.pool['account.tax']._fix_tax_included_price(cr, uid, price, product.supplier_taxes_id, taxes_ids)