-
-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TMP] include PR 937 from OCA/account-financial-reporting
- Loading branch information
Showing
35 changed files
with
5,598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
=========== | ||
Tax Balance | ||
=========== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Mature | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github | ||
:target: https://github.com/OCA/account-financial-reporting/tree/15.0/account_tax_balance | ||
:alt: OCA/account-financial-reporting | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/account-financial-reporting-15-0/account-financial-reporting-15-0-account_tax_balance | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/91/15.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows to compute tax balances within a certain date range. | ||
It depends on date_range module and exposes 'compute' methods that can be called by other modules | ||
(like localization ones). | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Accounting --> Reporting --> Taxes Balance | ||
|
||
Select the company, the date range, the target moves and 'open taxes' | ||
|
||
.. figure:: https://raw.githubusercontent.com/account_tax_balance/static/description/tax_balance.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_tax_balance%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Agile Business Group | ||
* Therp BV | ||
* Tecnativa | ||
* ACSONE SA/NV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Lorenzo Battistini <lorenzo.battistini@agilebg.com> | ||
* Giovanni Capalbo <giovanni@therp.nl> | ||
* Tecnativa - Antonio Espinosa | ||
* Tecnativa - Pedro M. Baeza | ||
* ACSONE SA/NV - Stéphane Bidoul | ||
* Andrea Stirpe <a.stirpe@onestein.nl> | ||
* Iván Antón <ozono@ozonomultimedia.com> | ||
* `Sygel <https://www.sygel.es>`__: | ||
|
||
* Valentin Vinagre | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/15.0/account_tax_balance>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from . import wizard | ||
from .hooks import pre_init_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2016 Lorenzo Battistini - Agile Business Group | ||
# Copyright 2016 Tecnativa - Antonio Espinosa | ||
# Copyright 2016 ACSONE SA/NV - Stéphane Bidoul | ||
# Copyright 2017 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Tax Balance", | ||
"summary": "Compute tax balances based on date range", | ||
"version": "16.0.1.0.0", | ||
"development_status": "Mature", | ||
"category": "Invoices & Payments", | ||
"website": "https://github.com/OCA/account-financial-reporting", | ||
"author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, " | ||
"Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["account", "date_range"], | ||
"data": [ | ||
"wizard/open_tax_balances_view.xml", | ||
"views/account_move_view.xml", | ||
"views/account_tax_view.xml", | ||
"security/ir.model.access.csv", | ||
], | ||
"images": ["images/tax_balance.png"], | ||
"pre_init_hook": "pre_init_hook", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2020 Opener B.V. <https://opener.amsterdam> | ||
# Copyright 2020 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
import logging | ||
|
||
from psycopg2 import sql | ||
|
||
|
||
def pre_init_hook(cr): | ||
"""Precreate financial_type and fill with appropriate values to prevent | ||
a MemoryError when the ORM attempts to call its compute method on a large | ||
amount of preexisting moves. Note that the order of the mapping is | ||
important as one move can have move lines on accounts of multiple types | ||
and the move type is set in the order of precedence.""" | ||
logger = logging.getLogger(__name__) | ||
logger.info("Add account_move.financial_type column if it does not yet exist") | ||
cr.execute( | ||
"ALTER TABLE account_move ADD COLUMN IF NOT EXISTS financial_type VARCHAR" | ||
) | ||
MAPPING = [ | ||
("liquidity", "asset_cash", False), | ||
("liquidity", "liability_credit_card", False), | ||
("payable", "liability_payable", "AND aml.balance < 0"), | ||
("payable_refund", "liability_payable", "AND aml.balance >= 0"), | ||
("receivable", "asset_receivable", "AND aml.balance > 0"), | ||
("receivable_refund", "asset_receivable", "AND aml.balance <= 0"), | ||
("other", False, False), | ||
] | ||
for financial_type, account_type, extra_where in MAPPING: | ||
args = [financial_type] | ||
query = sql.SQL("UPDATE account_move am SET financial_type = %s") | ||
if account_type: | ||
query += sql.SQL( | ||
"""FROM account_move_line aml | ||
WHERE aml.account_id IN ( | ||
SELECT id FROM account_account | ||
WHERE account_type = %s) | ||
AND aml.move_id = am.id AND am.financial_type IS NULL | ||
""" | ||
) | ||
args.append(account_type) | ||
else: | ||
query += sql.SQL("WHERE am.financial_type IS NULL") | ||
if extra_where: | ||
query += sql.SQL(extra_where) | ||
cr.execute(query, tuple(args)) | ||
logger.info("%s move set to type %s", financial_type, cr.rowcount) |
Oops, something went wrong.