[ADD] account_cash_basis_base_account: add module to change the base amount account in tax cash basis entries

To be able to retrieve the base amount of cash basis taxes lines, additional journal items are created for the base as well in the journal entry generated by the payment.
However, these additional journal items debitting and creditting the same account are considered as pollution in reports.

This module and hook allow to move these additional lines to an another account, if needed.

    -task: https://www.odoo.com/web#id=35605&view_type=form&model=project.task&action=333&active_id=967&menu_id=4720
    Was PR #23349
This commit is contained in:
Laurent Smet
2018-03-29 18:03:32 +02:00
committed by qdp-odoo
parent 97fc813a1a
commit 1631889e91
6 changed files with 74 additions and 2 deletions
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import account_tax
import account_partial_reconcile
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name' : 'Tax Cash Basis Edit Base Account',
'version' : '1.0',
'summary': 'Add a custom account to handle base amount lines',
'sequence': 5,
'description': """
Move the cash basis lines to another account.
""",
'category': 'Accounting',
'depends': ['account_tax_cash_basis'],
'data': [
'views/account_tax_views.xml',
],
'installable': True,
'auto_install': True,
}
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import api, models
class AccountPartialReconcileCashBasis(models.Model):
_inherit = 'account.partial.reconcile'
def _get_tax_cash_basis_base_account(self, line, tax):
if tax.cash_basis_base_account_id:
return tax.cash_basis_base_account_id
return super(AccountPartialReconcileCashBasis, self)._get_tax_cash_basis_base_account(line, tax)
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from openerp import api, fields, models
class AccountTax(models.Model):
_inherit = 'account.tax'
cash_basis_base_account_id = fields.Many2one('account.account', domain=[('deprecated', '=', False)],
string='Base Tax Received Account',
help='Account that will be set on lines created in cash basis journal entry and used to keep track of the tax base amount.')
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_tax_form_cash_basis_inherit" model="ir.ui.view">
<field name="name">tax.form.cash.basis.base.account.inherit</field>
<field name="model">account.tax</field>
<field name="inherit_id" ref="account_tax_cash_basis.view_tax_form_cash_basis_inherit"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='cash_basis_account']" position="after">
<field name="cash_basis_base_account_id" attrs="{'invisible': [('use_cash_basis', '=', False)]}"/>
</xpath>
</field>
</record>
</data>
</openerp>
@@ -39,6 +39,15 @@ class AccountPartialReconcileCashBasis(models.Model):
""" Function overwritten in account_tax_exigible to make sure we consider only the lines having tax_exigible set to False """
return False
def _get_tax_cash_basis_base_account(self, line, tax):
''' Get the account of lines that will contain the base amount of taxes.
:param line: An account.move.line record
:param tax: An account.tax record
:return: An account record
'''
return line.account_id
def _get_tax_cash_basis_lines(self, value_before_reconciliation):
# Search in account_move if we have any taxes account move lines
tax_group = {}
@@ -71,19 +80,20 @@ class AccountPartialReconcileCashBasis(models.Model):
else:
total_by_cash_basis_account[key] = amount
if any([tax.use_cash_basis for tax in line.tax_ids]):
account_id = self._get_tax_cash_basis_base_account(line, tax)
for tax in line.tax_ids:
line_to_create.append((0, 0, {
'name': '/',
'debit': currency_id.round(line.debit_cash_basis - line.debit * matched_percentage),
'credit': currency_id.round(line.credit_cash_basis - line.credit * matched_percentage),
'account_id': line.account_id.id,
'account_id': account_id.id,
'tax_ids': [(6, 0, [tax.id])],
}))
line_to_create.append((0, 0, {
'name': '/',
'credit': currency_id.round(line.debit_cash_basis - line.debit * matched_percentage),
'debit': currency_id.round(line.credit_cash_basis - line.credit * matched_percentage),
'account_id': line.account_id.id,
'account_id': account_id.id,
}))
for k, v in tax_group.items():