[IMP]account: allow excluding some tax repartition lines from the tax closing entry
TASK ID : 2212170 closes odoo/odoo#47979 Related: odoo/enterprise#9356 Related: odoo/upgrade#999 Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
@@ -2004,6 +2004,14 @@ class AccountTaxRepartitionLine(models.Model):
|
||||
country_id = fields.Many2one(string="Country", comodel_name='res.country', related='company_id.country_id', help="Technical field used to restrict tags domain in form view.")
|
||||
company_id = fields.Many2one(string="Company", comodel_name='res.company', compute="_compute_company", store=True, help="The company this repartition line belongs to.")
|
||||
sequence = fields.Integer(string="Sequence", default=1, help="The order in which display and match repartition lines. For refunds to work properly, invoice repartition lines should be arranged in the same order as the credit note repartition lines they correspond to.")
|
||||
use_in_tax_closing = fields.Boolean(string="Tax Closing Entry")
|
||||
|
||||
@api.onchange('account_id')
|
||||
def _on_change_account_id(self):
|
||||
if not self.account_id:
|
||||
self.use_in_tax_closing = False
|
||||
else:
|
||||
self.use_in_tax_closing = not(self.account_id.internal_group == 'income' or self.account_id.internal_group == 'expense')
|
||||
|
||||
@api.constrains('invoice_tax_id', 'refund_tax_id')
|
||||
def validate_tax_template_link(self):
|
||||
|
||||
@@ -983,6 +983,7 @@ class AccountTaxTemplate(models.Model):
|
||||
|
||||
# Tax Repartition Line Template
|
||||
|
||||
|
||||
class AccountTaxRepartitionLineTemplate(models.Model):
|
||||
_name = "account.tax.repartition.line.template"
|
||||
_description = "Tax Repartition Line Template"
|
||||
@@ -993,6 +994,7 @@ class AccountTaxRepartitionLineTemplate(models.Model):
|
||||
invoice_tax_id = fields.Many2one(comodel_name='account.tax.template', help="The tax set to apply this repartition on invoices. Mutually exclusive with refund_tax_id")
|
||||
refund_tax_id = fields.Many2one(comodel_name='account.tax.template', help="The tax set to apply this repartition on refund invoices. Mutually exclusive with invoice_tax_id")
|
||||
tag_ids = fields.Many2many(string="Financial Tags", relation='account_tax_repartition_financial_tags', comodel_name='account.account.tag', copy=True, help="Additional tags that will be assigned by this repartition line for use in financial reports")
|
||||
use_in_tax_closing = fields.Boolean(string="Tax Closing Entry")
|
||||
|
||||
# These last two fields are helpers used to ease the declaration of account.account.tag objects in XML.
|
||||
# They are directly linked to account.tax.report.line objects, which create corresponding + and - tags
|
||||
@@ -1003,7 +1005,7 @@ class AccountTaxRepartitionLineTemplate(models.Model):
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('plus_report_line_ids'):
|
||||
vals['plus_report_line_ids'] = self._convert_tag_syntax_to_orm(vals['plus_report_line_ids'])
|
||||
vals['plus_report_line_ids'] = self._convert_tag_syntax_to_orm(vals['plus_report_line_ids'])
|
||||
|
||||
if vals.get('minus_report_line_ids'):
|
||||
vals['minus_report_line_ids'] = self._convert_tag_syntax_to_orm(vals['minus_report_line_ids'])
|
||||
@@ -1011,6 +1013,13 @@ class AccountTaxRepartitionLineTemplate(models.Model):
|
||||
if vals.get('tag_ids'):
|
||||
vals['tag_ids'] = self._convert_tag_syntax_to_orm(vals['tag_ids'])
|
||||
|
||||
if vals.get('use_in_tax_closing') is None:
|
||||
if not vals.get('account_id'):
|
||||
vals['use_in_tax_closing'] = False
|
||||
else:
|
||||
internal_group = self.env['account.account.template'].browse(vals.get('account_id')).user_type_id.internal_group
|
||||
vals['use_in_tax_closing'] = not (internal_group == 'income' or internal_group == 'expense')
|
||||
|
||||
return super(AccountTaxRepartitionLineTemplate, self).create(vals)
|
||||
|
||||
@api.model
|
||||
@@ -1051,6 +1060,7 @@ class AccountTaxRepartitionLineTemplate(models.Model):
|
||||
'repartition_type': record.repartition_type,
|
||||
'tag_ids': [(6, 0, tags_to_add.ids)],
|
||||
'company_id': company.id,
|
||||
'use_in_tax_closing': record.use_in_tax_closing
|
||||
}))
|
||||
return rslt
|
||||
|
||||
|
||||
@@ -1078,6 +1078,7 @@ action = model.setting_init_bank_account_action()
|
||||
<field name="repartition_type"/>
|
||||
<field name="account_id" attrs="{'invisible': [('repartition_type', '=', 'base')]}" options="{'no_create': True}"/>
|
||||
<field name="tag_ids" widget="many2many_tags" options="{'no_create': True}" domain="[('applicability', '=', 'taxes'), ('country_id', '=', country_id)]"/>
|
||||
<field name="use_in_tax_closing" optional="hidden" />
|
||||
<field name="country_id" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user