Cash basis taxes use a distinct transition account on their tax lines; the tax account set on the repartition lines is only used when the payment is received, on the cash basis move. In enterprise, the bank reconciliation widget allows setting a tax on the manual write-off done for a statement line. When doing so, we expect the tax to behave just like on an invoice. For cash basis taxes, this means the "final" tax account has to be used instead of the transition one ; it wasn't the case. OPW 3255511 X-original-commit: 991fa46081296c3560bd7ca195996693a81a46b8 Part-of: odoo/odoo#120924
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models, _
|
|
from odoo.exceptions import ValidationError
|
|
from odoo import tools
|
|
|
|
|
|
class AccountMoveLine(models.Model):
|
|
_inherit = "account.move.line"
|
|
|
|
def init(self):
|
|
tools.create_index(self._cr, 'account_move_line_move_product_index', self._table, ['move_id', 'product_id'])
|
|
|
|
@api.depends('move_id.line_ids', 'move_id.line_ids.tax_line_id', 'move_id.line_ids.debit', 'move_id.line_ids.credit')
|
|
def _compute_tax_base_amount(self):
|
|
aml = self.filtered(lambda l: l.company_id.account_fiscal_country_id.code == 'IN' and l.tax_line_id and l.product_id)
|
|
for move_line in aml:
|
|
base_lines = move_line.move_id.line_ids.filtered(lambda line: move_line.tax_line_id in line.tax_ids and move_line.product_id == line.product_id)
|
|
move_line.tax_base_amount = abs(sum(base_lines.mapped('balance')))
|
|
remaining_aml = self - aml
|
|
if remaining_aml:
|
|
return super(AccountMoveLine, remaining_aml)._compute_tax_base_amount()
|
|
|
|
|
|
class AccountTax(models.Model):
|
|
_inherit = 'account.tax'
|
|
|
|
l10n_in_reverse_charge = fields.Boolean("Reverse charge", help="Tick this if this tax is reverse charge. Only for Indian accounting")
|
|
|
|
@api.model
|
|
def _get_generation_dict_from_base_line(self, line_vals, tax_vals, force_caba_exigibility=False):
|
|
# EXTENDS account
|
|
# Group taxes also by product.
|
|
res = super()._get_generation_dict_from_base_line(line_vals, tax_vals, force_caba_exigibility=force_caba_exigibility)
|
|
record = line_vals['record']
|
|
if isinstance(record, models.Model)\
|
|
and record._name == 'account.move.line'\
|
|
and record.company_id.account_fiscal_country_id.code == 'IN':
|
|
res['product_id'] = record.product_id.id
|
|
res['product_uom_id'] = record.product_uom_id.id
|
|
return res
|
|
|
|
@api.model
|
|
def _get_generation_dict_from_tax_line(self, line_vals):
|
|
# EXTENDS account
|
|
# Group taxes also by product.
|
|
res = super()._get_generation_dict_from_tax_line(line_vals)
|
|
record = line_vals['record']
|
|
if isinstance(record, models.Model)\
|
|
and record._name == 'account.move.line'\
|
|
and record.company_id.account_fiscal_country_id.code == 'IN':
|
|
res['product_id'] = record.product_id.id
|
|
res['product_uom_id'] = record.product_uom_id.id
|
|
return res
|