[IMP] *: do not filter the taxes twice for nothing

Since _filter_included_tax_company filters the taxes of other companies,
there is no need to give taxes from other companies if the filtering was
already done.

closes odoo/odoo#71591

Related: odoo/enterprise#18670
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2021-06-17 12:14:36 +00:00
parent 7ab7bd92ea
commit 2e3dac8da0
4 changed files with 15 additions and 14 deletions
+1 -1
View File
@@ -836,7 +836,7 @@ class PosOrderLine(models.Model):
self.product_id, self.qty or 1.0, self.order_id.partner_id)
self.tax_ids = self.product_id.taxes_id.filtered(lambda r: not self.company_id or r.company_id == self.company_id)
tax_ids_after_fiscal_position = self.order_id.fiscal_position_id.map_tax(self.tax_ids)
self.price_unit = self.env['account.tax']._fix_tax_included_price_company(price, self.product_id.taxes_id, tax_ids_after_fiscal_position, self.company_id)
self.price_unit = self.env['account.tax']._fix_tax_included_price_company(price, self.tax_ids, tax_ids_after_fiscal_position, self.company_id)
self._onchange_qty()
@api.onchange('qty', 'discount', 'price_unit', 'tax_ids')
+5 -7
View File
@@ -1285,13 +1285,11 @@ class PurchaseOrderLine(models.Model):
date=po.date_order and po.date_order.date(),
uom_id=product_id.uom_po_id)
taxes = product_id.supplier_taxes_id
fpos = po.fiscal_position_id
taxes_id = fpos.map_tax(taxes)
if taxes_id:
taxes_id = taxes_id.filtered(lambda x: x.company_id.id == company_id.id)
product_taxes = product_id.supplier_taxes_id.filtered(lambda x: x.company_id.id == company_id.id)
taxes = po.fiscal_position_id.map_tax(product_taxes)
price_unit = self.env['account.tax']._fix_tax_included_price_company(seller.price, product_id.supplier_taxes_id, taxes_id, company_id) if seller else 0.0
price_unit = self.env['account.tax']._fix_tax_included_price_company(
seller.price, product_taxes, taxes, company_id) if seller else 0.0
if price_unit and seller and po.currency_id and seller.currency_id != po.currency_id:
price_unit = seller.currency_id._convert(
price_unit, po.currency_id, po.company_id, po.date_order or fields.Date.today())
@@ -1313,7 +1311,7 @@ class PurchaseOrderLine(models.Model):
'product_uom': product_id.uom_po_id.id,
'price_unit': price_unit,
'date_planned': date_planned,
'taxes_id': [(6, 0, taxes_id.ids)],
'taxes_id': [(6, 0, taxes.ids)],
'order_id': po.id,
}
+3 -3
View File
@@ -229,14 +229,14 @@ class SaleOrderLine(models.Model):
date=purchase_order.date_order and purchase_order.date_order.date(), # and purchase_order.date_order[:10],
uom_id=self.product_id.uom_po_id
)
fpos = purchase_order.fiscal_position_id
supplier_taxes = self.product_id.supplier_taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
taxes = fpos.map_tax(supplier_taxes)
taxes = purchase_order.fiscal_position_id.map_tax(supplier_taxes)
# compute unit price
price_unit = 0.0
if supplierinfo:
price_unit = self.env['account.tax'].sudo()._fix_tax_included_price_company(supplierinfo.price, self.product_id.supplier_taxes_id, taxes, self.company_id)
price_unit = self.env['account.tax'].sudo()._fix_tax_included_price_company(
supplierinfo.price, supplier_taxes, taxes, self.company_id)
if purchase_order.currency_id and supplierinfo.currency_id != purchase_order.currency_id:
price_unit = supplierinfo.currency_id.compute(price_unit, purchase_order.currency_id)
+6 -3
View File
@@ -300,14 +300,17 @@ class ProductTemplate(models.Model):
tax_display = self.user_has_groups('account.group_show_line_subtotals_tax_excluded') and 'total_excluded' or 'total_included'
fpos = self.env['account.fiscal.position'].get_fiscal_position(partner.id).sudo()
taxes = fpos.map_tax(product.sudo().taxes_id.filtered(lambda x: x.company_id == company_id))
product_taxes = product.sudo().taxes_id.filtered(lambda x: x.company_id == company_id)
taxes = fpos.map_tax(product_taxes)
# The list_price is always the price of one.
quantity_1 = 1
combination_info['price'] = self.env['account.tax']._fix_tax_included_price_company(combination_info['price'], product.sudo().taxes_id, taxes, company_id)
combination_info['price'] = self.env['account.tax']._fix_tax_included_price_company(
combination_info['price'], product_taxes, taxes, company_id)
price = taxes.compute_all(combination_info['price'], pricelist.currency_id, quantity_1, product, partner)[tax_display]
if pricelist.discount_policy == 'without_discount':
combination_info['list_price'] = self.env['account.tax']._fix_tax_included_price_company(combination_info['list_price'], product.sudo().taxes_id, taxes, company_id)
combination_info['list_price'] = self.env['account.tax']._fix_tax_included_price_company(
combination_info['list_price'], product_taxes, taxes, company_id)
list_price = taxes.compute_all(combination_info['list_price'], pricelist.currency_id, quantity_1, product, partner)[tax_display]
else:
list_price = price