[IMP] account,*: clean map_tax definition
product and partner parameters are leftovers of an older definition of map_tax, and can now be safely removed.
This commit is contained in:
@@ -3307,7 +3307,7 @@ class AccountMoveLine(models.Model):
|
||||
|
||||
# Apply fiscal position.
|
||||
if product_taxes and fiscal_position:
|
||||
product_taxes_after_fp = fiscal_position.map_tax(product_taxes, partner=self.partner_id)
|
||||
product_taxes_after_fp = fiscal_position.map_tax(product_taxes)
|
||||
|
||||
if set(product_taxes.ids) != set(product_taxes_after_fp.ids):
|
||||
flattened_taxes_before_fp = product_taxes._origin.flatten_taxes_hierarchy()
|
||||
@@ -3409,9 +3409,7 @@ class AccountMoveLine(models.Model):
|
||||
# 100 as balance but set 120 as price_unit.
|
||||
if self.tax_ids and self.move_id.fiscal_position_id and self.move_id.fiscal_position_id.tax_ids:
|
||||
price_subtotal = self._get_price_total_and_subtotal()['price_subtotal']
|
||||
self.tax_ids = self.move_id.fiscal_position_id.map_tax(
|
||||
self.tax_ids._origin,
|
||||
partner=self.move_id.partner_id)
|
||||
self.tax_ids = self.move_id.fiscal_position_id.map_tax(self.tax_ids._origin)
|
||||
accounting_vals = self._get_fields_onchange_subtotal(
|
||||
price_subtotal=price_subtotal,
|
||||
currency=self.move_id.company_currency_id)
|
||||
@@ -3645,7 +3643,7 @@ class AccountMoveLine(models.Model):
|
||||
line.account_id = line._get_computed_account()
|
||||
taxes = line._get_computed_taxes()
|
||||
if taxes and line.move_id.fiscal_position_id:
|
||||
taxes = line.move_id.fiscal_position_id.map_tax(taxes, partner=line.partner_id)
|
||||
taxes = line.move_id.fiscal_position_id.map_tax(taxes)
|
||||
line.tax_ids = taxes
|
||||
line.product_uom_id = line._get_computed_uom()
|
||||
line.price_unit = line._get_computed_price_unit()
|
||||
@@ -3655,7 +3653,7 @@ class AccountMoveLine(models.Model):
|
||||
''' Recompute the 'price_unit' depending of the unit of measure. '''
|
||||
taxes = self._get_computed_taxes()
|
||||
if taxes and self.move_id.fiscal_position_id:
|
||||
taxes = self.move_id.fiscal_position_id.map_tax(taxes, partner=self.partner_id)
|
||||
taxes = self.move_id.fiscal_position_id.map_tax(taxes)
|
||||
self.tax_ids = taxes
|
||||
self.price_unit = self._get_computed_price_unit()
|
||||
|
||||
@@ -3669,7 +3667,7 @@ class AccountMoveLine(models.Model):
|
||||
taxes = line._get_computed_taxes()
|
||||
|
||||
if taxes and line.move_id.fiscal_position_id:
|
||||
taxes = line.move_id.fiscal_position_id.map_tax(taxes, partner=line.partner_id)
|
||||
taxes = line.move_id.fiscal_position_id.map_tax(taxes)
|
||||
|
||||
line.tax_ids = taxes
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class AccountFiscalPosition(models.Model):
|
||||
else:
|
||||
raise ValidationError(_("You cannot create a fiscal position with a foreign VAT within your fiscal country."))
|
||||
|
||||
def map_tax(self, taxes, product=None, partner=None):
|
||||
def map_tax(self, taxes):
|
||||
if not self:
|
||||
return taxes
|
||||
result = self.env['account.tax']
|
||||
|
||||
@@ -84,7 +84,7 @@ class SaleOrder(models.Model):
|
||||
taxes = carrier.product_id.taxes_id.filtered(lambda t: t.company_id.id == self.company_id.id)
|
||||
taxes_ids = taxes.ids
|
||||
if self.partner_id and self.fiscal_position_id:
|
||||
taxes_ids = self.fiscal_position_id.map_tax(taxes, carrier.product_id, self.partner_id).ids
|
||||
taxes_ids = self.fiscal_position_id.map_tax(taxes).ids
|
||||
|
||||
# Create the sales order line
|
||||
carrier_with_partner_lang = carrier.with_context(lang=self.partner_id.lang)
|
||||
|
||||
@@ -25,7 +25,7 @@ class PosOrder(models.Model):
|
||||
@api.model
|
||||
def _amount_line_tax(self, line, fiscal_position_id):
|
||||
taxes = line.tax_ids.filtered(lambda t: t.company_id.id == line.order_id.company_id.id)
|
||||
taxes = fiscal_position_id.map_tax(taxes, line.product_id, line.order_id.partner_id)
|
||||
taxes = fiscal_position_id.map_tax(taxes)
|
||||
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
||||
taxes = taxes.compute_all(price, line.order_id.pricelist_id.currency_id, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)['taxes']
|
||||
return sum(tax.get('amount', 0.0) for tax in taxes)
|
||||
@@ -817,7 +817,7 @@ class PosOrderLine(models.Model):
|
||||
def _compute_amount_line_all(self):
|
||||
self.ensure_one()
|
||||
fpos = self.order_id.fiscal_position_id
|
||||
tax_ids_after_fiscal_position = fpos.map_tax(self.tax_ids, self.product_id, self.order_id.partner_id)
|
||||
tax_ids_after_fiscal_position = fpos.map_tax(self.tax_ids)
|
||||
price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)
|
||||
taxes = tax_ids_after_fiscal_position.compute_all(price, self.order_id.pricelist_id.currency_id, self.qty, product=self.product_id, partner=self.order_id.partner_id)
|
||||
return {
|
||||
@@ -836,7 +836,7 @@ class PosOrderLine(models.Model):
|
||||
self.product_id, self.qty or 1.0, self.order_id.partner_id)
|
||||
self._onchange_qty()
|
||||
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.product_id, self.order_id.partner_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)
|
||||
|
||||
@api.onchange('qty', 'discount', 'price_unit', 'tax_ids')
|
||||
@@ -854,7 +854,7 @@ class PosOrderLine(models.Model):
|
||||
@api.depends('order_id', 'order_id.fiscal_position_id')
|
||||
def _get_tax_ids_after_fiscal_position(self):
|
||||
for line in self:
|
||||
line.tax_ids_after_fiscal_position = line.order_id.fiscal_position_id.map_tax(line.tax_ids, line.product_id, line.order_id.partner_id)
|
||||
line.tax_ids_after_fiscal_position = line.order_id.fiscal_position_id.map_tax(line.tax_ids)
|
||||
|
||||
def _export_for_ui(self, orderline):
|
||||
return {
|
||||
|
||||
@@ -940,7 +940,7 @@ class PurchaseOrderLine(models.Model):
|
||||
fpos = line.order_id.fiscal_position_id or line.order_id.fiscal_position_id.get_fiscal_position(line.order_id.partner_id.id)
|
||||
# filter taxes by company
|
||||
taxes = line.product_id.supplier_taxes_id.filtered(lambda r: r.company_id == line.env.company)
|
||||
line.taxes_id = fpos.map_tax(taxes, line.product_id, line.order_id.partner_id)
|
||||
line.taxes_id = fpos.map_tax(taxes)
|
||||
|
||||
@api.depends('invoice_lines.move_id.state', 'invoice_lines.quantity', 'qty_received', 'product_uom_qty', 'order_id.state')
|
||||
def _compute_qty_invoiced(self):
|
||||
@@ -1287,7 +1287,7 @@ class PurchaseOrderLine(models.Model):
|
||||
|
||||
taxes = product_id.supplier_taxes_id
|
||||
fpos = po.fiscal_position_id
|
||||
taxes_id = fpos.map_tax(taxes, product_id, seller.name)
|
||||
taxes_id = fpos.map_tax(taxes)
|
||||
if taxes_id:
|
||||
taxes_id = taxes_id.filtered(lambda x: x.company_id.id == company_id.id)
|
||||
|
||||
|
||||
@@ -711,7 +711,7 @@ class RepairLine(models.Model):
|
||||
if partner:
|
||||
fpos = self.env['account.fiscal.position'].get_fiscal_position(partner_invoice.id, delivery_id=self.repair_id.address_id.id)
|
||||
taxes = self.product_id.taxes_id.filtered(lambda x: x.company_id == self.repair_id.company_id)
|
||||
self.tax_id = fpos.map_tax(taxes, self.product_id, partner).ids
|
||||
self.tax_id = fpos.map_tax(taxes)
|
||||
warning = False
|
||||
pricelist = self.repair_id.pricelist_id
|
||||
if not pricelist:
|
||||
@@ -787,7 +787,7 @@ class RepairFee(models.Model):
|
||||
if partner and self.product_id:
|
||||
fpos = self.env['account.fiscal.position'].get_fiscal_position(partner_invoice.id, delivery_id=self.repair_id.address_id.id)
|
||||
taxes = self.product_id.taxes_id.filtered(lambda x: x.company_id == self.repair_id.company_id)
|
||||
self.tax_id = fpos.map_tax(taxes, self.product_id, partner).ids
|
||||
self.tax_id = fpos.map_tax(taxes)
|
||||
if partner:
|
||||
self.name = self.product_id.with_context(lang=partner.lang).display_name
|
||||
else:
|
||||
|
||||
@@ -158,7 +158,7 @@ class AccountMoveLine(models.Model):
|
||||
last_sequence = last_so_line.sequence + 1 if last_so_line else 100
|
||||
|
||||
fpos = order.fiscal_position_id or order.fiscal_position_id.get_fiscal_position(order.partner_id.id)
|
||||
taxes = fpos.map_tax(self.product_id.taxes_id, self.product_id, order.partner_id)
|
||||
taxes = fpos.map_tax(self.product_id.taxes_id)
|
||||
|
||||
return {
|
||||
'order_id': order.id,
|
||||
|
||||
@@ -132,7 +132,7 @@ class SaleOrderLine(models.Model):
|
||||
fpos = line.order_id.fiscal_position_id or line.order_id.fiscal_position_id.get_fiscal_position(line.order_partner_id.id)
|
||||
# If company_id is set, always filter taxes by the company
|
||||
taxes = line.product_id.taxes_id.filtered(lambda t: t.company_id == line.env.company)
|
||||
line.tax_id = fpos.map_tax(taxes, line.product_id, line.order_id.partner_shipping_id)
|
||||
line.tax_id = fpos.map_tax(taxes)
|
||||
|
||||
@api.model
|
||||
def _prepare_add_missing_fields(self, values):
|
||||
|
||||
@@ -170,7 +170,7 @@ class SaleAdvancePaymentInv(models.TransientModel):
|
||||
if self.product_id.type != 'service':
|
||||
raise UserError(_("The product used to invoice a down payment should be of type 'Service'. Please use another product or update this product."))
|
||||
taxes = self.product_id.taxes_id.filtered(lambda r: not order.company_id or r.company_id == order.company_id)
|
||||
tax_ids = order.fiscal_position_id.map_tax(taxes, self.product_id, order.partner_shipping_id).ids
|
||||
tax_ids = order.fiscal_position_id.map_tax(taxes).ids
|
||||
analytic_tag_ids = []
|
||||
for line in order.order_line:
|
||||
analytic_tag_ids = [(4, analytic_tag.id, None) for analytic_tag in line.analytic_tag_ids]
|
||||
|
||||
@@ -505,7 +505,7 @@ class SaleOrderLine(models.Model):
|
||||
fpos = line.order_id.fiscal_position_id or line.order_id.fiscal_position_id.get_fiscal_position(line.order_partner_id.id)
|
||||
# If company_id is set, always filter taxes by the company
|
||||
taxes = line.tax_id.filtered(lambda r: not line.company_id or r.company_id == line.company_id)
|
||||
line.tax_id = fpos.map_tax(taxes, line.product_id, line.order_id.partner_shipping_id)
|
||||
line.tax_id = fpos.map_tax(taxes)
|
||||
|
||||
# Invalidation of `coupon.program.order_count`
|
||||
# `test_program_rules_validity_dates_and_uses`,
|
||||
|
||||
@@ -300,7 +300,7 @@ 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, partner)
|
||||
taxes = fpos.map_tax(product.sudo().taxes_id.filtered(lambda x: x.company_id == company_id))
|
||||
|
||||
# The list_price is always the price of one.
|
||||
quantity_1 = 1
|
||||
|
||||
@@ -46,7 +46,7 @@ class WebsiteSaleDelivery(WebsiteSale):
|
||||
tax_ids = carrier.product_id.taxes_id.filtered(lambda t: t.company_id == order.company_id)
|
||||
if tax_ids:
|
||||
fpos = order.fiscal_position_id
|
||||
tax_ids = fpos.map_tax(tax_ids, carrier.product_id, order.partner_shipping_id)
|
||||
tax_ids = fpos.map_tax(tax_ids)
|
||||
taxes = tax_ids.compute_all(
|
||||
rate['price'],
|
||||
currency=order.currency_id,
|
||||
|
||||
Reference in New Issue
Block a user