diff --git a/account_tax_balance/README.rst b/account_tax_balance/README.rst index 10460b3e..2a6cffbc 100644 --- a/account_tax_balance/README.rst +++ b/account_tax_balance/README.rst @@ -14,13 +14,13 @@ Tax Balance :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/12.0/account_tax_balance + :target: https://github.com/OCA/account-financial-reporting/tree/13.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-12-0/account-financial-reporting-12-0-account_tax_balance + :target: https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-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/12.0 + :target: https://runbot.odoo-community.org/runbot/91/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -49,7 +49,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -87,6 +87,6 @@ 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 `_ project on GitHub. +This module is part of the `OCA/account-financial-reporting `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_tax_balance/hooks.py b/account_tax_balance/hooks.py index 2fa89e8e..1fafad71 100644 --- a/account_tax_balance/hooks.py +++ b/account_tax_balance/hooks.py @@ -1,7 +1,10 @@ -# © 2020 Opener B.V. +# Copyright 2020 Opener B.V. +# 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 move_type and fill with appropriate values to prevent @@ -10,66 +13,32 @@ def pre_init_hook(cr): 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.move_type column if it does not yet exist') - cr.execute( - "ALTER TABLE account_move ADD COLUMN IF NOT EXISTS move_type VARCHAR") - cr.execute( - """ - UPDATE account_move am SET move_type = 'liquidity' - FROM account_move_line aml - WHERE aml.account_id IN ( - SELECT id FROM account_account - WHERE internal_type = 'liquidity') - AND aml.move_id = am.id AND am.move_type IS NULL - """) - logger.info('%s move set to type liquidity', cr.rowcount) - cr.execute( - """ - UPDATE account_move am SET move_type = 'payable' - FROM account_move_line aml - WHERE aml.account_id IN ( - SELECT id FROM account_account - WHERE internal_type = 'payable') - AND aml.move_id = am.id AND am.move_type IS NULL - AND aml.balance < 0 - """) - logger.info('%s move set to type payable', cr.rowcount) - cr.execute( - """ - UPDATE account_move am SET move_type = 'payable_refund' - FROM account_move_line aml - WHERE aml.account_id IN ( - SELECT id FROM account_account - WHERE internal_type = 'payable') - AND aml.move_id = am.id AND am.move_type IS NULL - AND aml.balance >= 0 - """) - logger.info('%s move set to type payable_refund', cr.rowcount) - cr.execute( - """ - UPDATE account_move am SET move_type = 'receivable' - FROM account_move_line aml - WHERE aml.account_id IN ( - SELECT id FROM account_account - WHERE internal_type = 'receivable') - AND aml.move_id = am.id AND am.move_type IS NULL - AND aml.balance > 0 - """) - logger.info('%s move set to type receivable', cr.rowcount) - cr.execute( - """ - UPDATE account_move am SET move_type = 'receivable_refund' - FROM account_move_line aml - WHERE aml.account_id IN ( - SELECT id FROM account_account - WHERE internal_type = 'receivable') - AND aml.move_id = am.id AND am.move_type IS NULL - AND aml.balance <= 0 - """) - logger.info('%s move set to type receivable_refund', cr.rowcount) - cr.execute( - """ - UPDATE account_move am SET move_type = 'other' - WHERE am.move_type IS NULL - """) - logger.info('%s move set to type other', cr.rowcount) + logger.info("Add account_move.move_type column if it does not yet exist") + cr.execute("ALTER TABLE account_move ADD COLUMN IF NOT EXISTS move_type VARCHAR") + MAPPING = [ + ("liquidity", "liquidity", False), + ("payable", "payable", "AND aml.balance < 0"), + ("payable_refund", "payable", "AND aml.balance >= 0"), + ("receivable", "receivable", "AND aml.balance < 0"), + ("receivable_refund", "receivable", "AND aml.balance >= 0"), + ("other", False, False), + ] + for move_type, internal_type, extra_where in MAPPING: + args = [move_type] + query = sql.SQL("UPDATE account_move am SET move_type = %s") + if internal_type: + query += sql.SQL( + """FROM account_move_line aml + WHERE aml.account_id IN ( + SELECT id FROM account_account + WHERE internal_type = %s) + AND aml.move_id = am.id AND am.move_type IS NULL + """ + ) + args.append(internal_type) + else: + query += sql.SQL("WHERE am.move_type IS NULL") + if extra_where: + query += sql.SQL(extra_where) + cr.execute(query, tuple(args)) + logger.info("%s move set to type %s", move_type, cr.rowcount) diff --git a/account_tax_balance/i18n/account_tax_balance.pot b/account_tax_balance/i18n/account_tax_balance.pot index 2c154f2f..69ea4ab1 100644 --- a/account_tax_balance/i18n/account_tax_balance.pot +++ b/account_tax_balance/i18n/account_tax_balance.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * account_tax_balance +# * account_tax_balance # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -14,16 +14,11 @@ msgstr "" "Plural-Forms: \n" #. module: account_tax_balance -#: code:addons/account_tax_balance/wizard/open_tax_balances.py:48 +#: code:addons/account_tax_balance/wizard/open_tax_balances.py:0 #, python-format msgid "%(name)s: %(target)s from %(from)s to %(to)s" msgstr "" -#. module: account_tax_balance -#: model_terms:ir.ui.view,arch_db:account_tax_balance.view_tax_search_balance -msgid "Account" -msgstr "" - #. module: account_tax_balance #: model_terms:ir.ui.view,arch_db:account_tax_balance.view_tax_search_balance #: model_terms:ir.ui.view,arch_db:account_tax_balance.view_tax_tree_balance @@ -31,12 +26,12 @@ msgid "Account Tax" msgstr "" #. module: account_tax_balance -#: selection:wizard.open.tax.balances,target_move:0 +#: model:ir.model.fields.selection,name:account_tax_balance.selection__wizard_open_tax_balances__target_move__all msgid "All Entries" msgstr "" #. module: account_tax_balance -#: selection:wizard.open.tax.balances,target_move:0 +#: model:ir.model.fields.selection,name:account_tax_balance.selection__wizard_open_tax_balances__target_move__posted msgid "All Posted Entries" msgstr "" @@ -87,7 +82,7 @@ msgstr "" #. module: account_tax_balance #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__date_range_id -msgid "Date range" +msgid "Date Range" msgstr "" #. module: account_tax_balance @@ -97,7 +92,7 @@ msgstr "" #. module: account_tax_balance #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__from_date -msgid "From date" +msgid "From Date" msgstr "" #. module: account_tax_balance @@ -192,7 +187,7 @@ msgstr "" #. module: account_tax_balance #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__to_date -msgid "To date" +msgid "To Date" msgstr "" #. module: account_tax_balance @@ -211,7 +206,7 @@ msgid "Total Base Balance" msgstr "" #. module: account_tax_balance -#: code:addons/account_tax_balance/models/account_tax.py:90 +#: code:addons/account_tax_balance/models/account_tax.py:0 #, python-format msgid "Unsupported search operator" msgstr "" @@ -255,4 +250,3 @@ msgstr "" #: model_terms:ir.ui.view,arch_db:account_tax_balance.wizard_open_tax_balances msgid "or" msgstr "" - diff --git a/account_tax_balance/static/description/index.html b/account_tax_balance/static/description/index.html index 82b4d2a5..b89550d5 100644 --- a/account_tax_balance/static/description/index.html +++ b/account_tax_balance/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/account-financial-reporting Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/account-financial-reporting Translate me on Weblate Try me on Runbot

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).

@@ -397,7 +397,7 @@ It depends on date_range module and exposes ‘compute’ methods that can be ca

Bugs are tracked on GitHub 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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -429,7 +429,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/account-financial-reporting project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.