diff --git a/account_tax_balance/README.rst b/account_tax_balance/README.rst
index 2a6cffbc..8344db2c 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/13.0/account_tax_balance
+ :target: https://github.com/OCA/account-financial-reporting/tree/14.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-13-0/account-financial-reporting-13-0-account_tax_balance
+ :target: https://translation.odoo-community.org/projects/account-financial-reporting-14-0/account-financial-reporting-14-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/13.0
+ :target: https://runbot.odoo-community.org/runbot/91/14.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.
@@ -73,6 +73,7 @@ Contributors
* Tecnativa - Pedro M. Baeza
* ACSONE SA/NV - Stéphane Bidoul
* Andrea Stirpe
+* Iván Antón
Maintainers
~~~~~~~~~~~
@@ -87,6 +88,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/__manifest__.py b/account_tax_balance/__manifest__.py
index 03993cb6..a179f5df 100644
--- a/account_tax_balance/__manifest__.py
+++ b/account_tax_balance/__manifest__.py
@@ -6,7 +6,7 @@
{
"name": "Tax Balance",
"summary": "Compute tax balances based on date range",
- "version": "13.0.1.0.1",
+ "version": "14.0.1.0.0",
"category": "Invoices & Payments",
"website": "https://github.com/OCA/account-financial-reporting",
"author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, "
@@ -18,6 +18,7 @@
"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",
diff --git a/account_tax_balance/hooks.py b/account_tax_balance/hooks.py
index bdc693a5..55e5a1cd 100644
--- a/account_tax_balance/hooks.py
+++ b/account_tax_balance/hooks.py
@@ -7,14 +7,16 @@ from psycopg2 import sql
def pre_init_hook(cr):
- """Precreate move_type and fill with appropriate values to prevent
+ """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.move_type column if it does not yet exist")
- cr.execute("ALTER TABLE account_move ADD COLUMN IF NOT EXISTS move_type VARCHAR")
+ 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", "liquidity", False),
("payable", "payable", "AND aml.balance < 0"),
@@ -23,22 +25,22 @@ def pre_init_hook(cr):
("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")
+ for financial_type, internal_type, extra_where in MAPPING:
+ args = [financial_type]
+ query = sql.SQL("UPDATE account_move am SET financial_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
+ AND aml.move_id = am.id AND am.financial_type IS NULL
"""
)
args.append(internal_type)
else:
- query += sql.SQL("WHERE am.move_type IS NULL")
+ 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", move_type, cr.rowcount)
+ logger.info("%s move set to type %s", financial_type, cr.rowcount)
diff --git a/account_tax_balance/i18n/account_tax_balance.pot b/account_tax_balance/i18n/account_tax_balance.pot
index 604d5748..fcd850ac 100644
--- a/account_tax_balance/i18n/account_tax_balance.pot
+++ b/account_tax_balance/i18n/account_tax_balance.pot
@@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 13.0\n"
+"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -86,10 +86,20 @@ msgid "Date Range"
msgstr ""
#. module: account_tax_balance
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move__display_name
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move_line__display_name
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_tax__display_name
#: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__display_name
msgid "Display Name"
msgstr ""
+#. module: account_tax_balance
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_bank_statement_line__financial_type
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move__financial_type
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_payment__financial_type
+msgid "Financial Type"
+msgstr ""
+
#. module: account_tax_balance
#: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__from_date
msgid "From Date"
@@ -106,13 +116,16 @@ msgid "Has balance in period"
msgstr ""
#. module: account_tax_balance
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move__id
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move_line__id
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_tax__id
#: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__id
msgid "ID"
msgstr ""
#. module: account_tax_balance
#: model:ir.model,name:account_tax_balance.model_account_move
-msgid "Journal Entries"
+msgid "Journal Entry"
msgstr ""
#. module: account_tax_balance
@@ -121,6 +134,9 @@ msgid "Journal Item"
msgstr ""
#. module: account_tax_balance
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move____last_update
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_move_line____last_update
+#: model:ir.model.fields,field_description:account_tax_balance.field_account_tax____last_update
#: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances____last_update
msgid "Last Modified on"
msgstr ""
@@ -135,11 +151,6 @@ msgstr ""
msgid "Last Updated on"
msgstr ""
-#. module: account_tax_balance
-#: model:ir.model.fields,field_description:account_tax_balance.field_account_move__move_type
-msgid "Move Type"
-msgstr ""
-
#. module: account_tax_balance
#: model_terms:ir.ui.view,arch_db:account_tax_balance.view_account_move_filter
msgid "Move type"
diff --git a/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py b/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py
new file mode 100644
index 00000000..3d7a40e6
--- /dev/null
+++ b/account_tax_balance/migrations/14.0.1.0.0/pre-migration.py
@@ -0,0 +1,17 @@
+# Copyright 2020 Ozono Multimedia S.L.L.
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
+from openupgradelib import openupgrade
+
+field_renames = [
+ (
+ "account.move",
+ "account_move",
+ "move_type",
+ "financial_type",
+ ),
+]
+
+
+@openupgrade.migrate()
+def migrate(env, version):
+ openupgrade.rename_fields(env, field_renames)
diff --git a/account_tax_balance/models/account_move.py b/account_tax_balance/models/account_move.py
index bc54a4d0..e0919bfa 100644
--- a/account_tax_balance/models/account_move.py
+++ b/account_tax_balance/models/account_move.py
@@ -8,7 +8,7 @@ class AccountMove(models.Model):
_inherit = "account.move"
@api.model
- def _selection_move_type(self):
+ def _selection_financial_type(self):
return [
("other", "Other"),
("liquidity", "Liquidity"),
@@ -18,9 +18,9 @@ class AccountMove(models.Model):
("payable_refund", "Payable refund"),
]
- move_type = fields.Selection(
- selection="_selection_move_type",
- compute="_compute_move_type",
+ financial_type = fields.Selection(
+ selection="_selection_financial_type",
+ compute="_compute_financial_type",
store=True,
readonly=True,
)
@@ -30,7 +30,7 @@ class AccountMove(models.Model):
"line_ids.balance",
"line_ids.account_id.user_type_id.type",
)
- def _compute_move_type(self):
+ def _compute_financial_type(self):
def _balance_get(line_ids, internal_type):
return sum(
line_ids.filtered(
@@ -41,12 +41,14 @@ class AccountMove(models.Model):
for move in self:
internal_types = move.line_ids.mapped("account_id.internal_type")
if "liquidity" in internal_types:
- move.move_type = "liquidity"
+ move.financial_type = "liquidity"
elif "payable" in internal_types:
balance = _balance_get(move.line_ids, "payable")
- move.move_type = "payable" if balance < 0 else "payable_refund"
+ move.financial_type = "payable" if balance < 0 else "payable_refund"
elif "receivable" in internal_types:
balance = _balance_get(move.line_ids, "receivable")
- move.move_type = "receivable" if balance > 0 else "receivable_refund"
+ move.financial_type = (
+ "receivable" if balance > 0 else "receivable_refund"
+ )
else:
- move.move_type = "other"
+ move.financial_type = "other"
diff --git a/account_tax_balance/models/account_tax.py b/account_tax_balance/models/account_tax.py
index 243bf65e..60f86b42 100644
--- a/account_tax_balance/models/account_tax.py
+++ b/account_tax_balance/models/account_tax.py
@@ -86,24 +86,24 @@ class AccountTax(models.Model):
def _compute_balance(self):
for tax in self:
tax.balance_regular = tax.compute_balance(
- tax_or_base="tax", move_type="regular"
+ tax_or_base="tax", financial_type="regular"
)
tax.base_balance_regular = tax.compute_balance(
- tax_or_base="base", move_type="regular"
+ tax_or_base="base", financial_type="regular"
)
tax.balance_refund = tax.compute_balance(
- tax_or_base="tax", move_type="refund"
+ tax_or_base="tax", financial_type="refund"
)
tax.base_balance_refund = tax.compute_balance(
- tax_or_base="base", move_type="refund"
+ tax_or_base="base", financial_type="refund"
)
tax.balance = tax.balance_regular + tax.balance_refund
tax.base_balance = tax.base_balance_regular + tax.base_balance_refund
- def get_target_type_list(self, move_type=None):
- if move_type == "refund":
+ def get_target_type_list(self, financial_type=None):
+ if financial_type == "refund":
return ["receivable_refund", "payable_refund"]
- elif move_type == "regular":
+ elif financial_type == "regular":
return ["receivable", "payable", "liquidity", "other"]
return []
@@ -123,10 +123,10 @@ class AccountTax(models.Model):
("company_id", "in", company_ids),
]
- def compute_balance(self, tax_or_base="tax", move_type=None):
+ def compute_balance(self, tax_or_base="tax", financial_type=None):
self.ensure_one()
domain = self.get_move_lines_domain(
- tax_or_base=tax_or_base, move_type=move_type
+ tax_or_base=tax_or_base, financial_type=financial_type
)
# balance is debit - credit whereas on tax return you want to see what
# vat has to be paid so:
@@ -144,7 +144,7 @@ class AccountTax(models.Model):
("tax_exigible", "=", True),
]
if type_list:
- domain.append(("move_id.move_type", "in", type_list))
+ domain.append(("move_id.financial_type", "in", type_list))
return domain
def get_base_balance_domain(self, state_list, type_list):
@@ -154,13 +154,13 @@ class AccountTax(models.Model):
("tax_exigible", "=", True),
]
if type_list:
- domain.append(("move_id.move_type", "in", type_list))
+ domain.append(("move_id.financial_type", "in", type_list))
return domain
- def get_move_lines_domain(self, tax_or_base="tax", move_type=None):
+ def get_move_lines_domain(self, tax_or_base="tax", financial_type=None):
from_date, to_date, company_ids, target_move = self.get_context_values()
state_list = self.get_target_state_list(target_move)
- type_list = self.get_target_type_list(move_type)
+ type_list = self.get_target_type_list(financial_type)
domain = self.get_move_line_partial_domain(from_date, to_date, company_ids)
balance_domain = []
if tax_or_base == "tax":
@@ -170,12 +170,12 @@ class AccountTax(models.Model):
domain.extend(balance_domain)
return domain
- def get_lines_action(self, tax_or_base="tax", move_type=None):
+ def get_lines_action(self, tax_or_base="tax", financial_type=None):
domain = self.get_move_lines_domain(
- tax_or_base=tax_or_base, move_type=move_type
+ tax_or_base=tax_or_base, financial_type=financial_type
)
action = self.env.ref("account.action_account_moves_all_tree")
- vals = action.read()[0]
+ vals = action.sudo().read()[0]
vals["context"] = {}
vals["domain"] = domain
return vals
@@ -190,16 +190,16 @@ class AccountTax(models.Model):
def view_tax_regular_lines(self):
self.ensure_one()
- return self.get_lines_action(tax_or_base="tax", move_type="regular")
+ return self.get_lines_action(tax_or_base="tax", financial_type="regular")
def view_base_regular_lines(self):
self.ensure_one()
- return self.get_lines_action(tax_or_base="base", move_type="regular")
+ return self.get_lines_action(tax_or_base="base", financial_type="regular")
def view_tax_refund_lines(self):
self.ensure_one()
- return self.get_lines_action(tax_or_base="tax", move_type="refund")
+ return self.get_lines_action(tax_or_base="tax", financial_type="refund")
def view_base_refund_lines(self):
self.ensure_one()
- return self.get_lines_action(tax_or_base="base", move_type="refund")
+ return self.get_lines_action(tax_or_base="base", financial_type="refund")
diff --git a/account_tax_balance/readme/CONTRIBUTORS.rst b/account_tax_balance/readme/CONTRIBUTORS.rst
index 2712f89b..9d50d806 100644
--- a/account_tax_balance/readme/CONTRIBUTORS.rst
+++ b/account_tax_balance/readme/CONTRIBUTORS.rst
@@ -4,3 +4,4 @@
* Tecnativa - Pedro M. Baeza
* ACSONE SA/NV - Stéphane Bidoul
* Andrea Stirpe
+* Iván Antón
diff --git a/account_tax_balance/security/ir.model.access.csv b/account_tax_balance/security/ir.model.access.csv
new file mode 100644
index 00000000..282f560f
--- /dev/null
+++ b/account_tax_balance/security/ir.model.access.csv
@@ -0,0 +1,3 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_wizard_open_tax_balances_user,access_wizard_open_tax_balances,model_wizard_open_tax_balances,account.group_account_user,1,1,1,1
+access_wizard_open_tax_balances_manager,access_wizard_open_tax_balances,model_wizard_open_tax_balances,account.group_account_manager,1,1,1,1
diff --git a/account_tax_balance/static/description/index.html b/account_tax_balance/static/description/index.html
index b89550d5..f358f0dc 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. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

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.
@@ -420,6 +420,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
Tecnativa - Pedro M. Baeza
ACSONE SA/NV - Stéphane Bidoul
Andrea Stirpe <a.stirpe@onestein.nl>
+
Iván Antón <ozono@ozonomultimedia.com>
@@ -429,7 +430,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.
diff --git a/account_tax_balance/tests/test_account_tax_balance.py b/account_tax_balance/tests/test_account_tax_balance.py
index 440857f3..0f11a27c 100644
--- a/account_tax_balance/tests/test_account_tax_balance.py
+++ b/account_tax_balance/tests/test_account_tax_balance.py
@@ -16,8 +16,10 @@ from odoo.tests.common import HttpCase
class TestAccountTaxBalance(HttpCase):
def setUp(self):
super().setUp()
+
+ self.company = self.env.user.company_id
self.range_type = self.env["date.range.type"].create(
- {"name": "Fiscal year", "company_id": False, "allow_overlap": False}
+ {"name": "Fiscal year", "allow_overlap": False}
)
self.range_generator = self.env["date.range.generator"]
self.current_year = datetime.now().year
@@ -69,7 +71,7 @@ class TestAccountTaxBalance(HttpCase):
invoice = self.env["account.move"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
- "type": "out_invoice",
+ "move_type": "out_invoice",
"invoice_line_ids": [
(
0,
@@ -152,7 +154,7 @@ class TestAccountTaxBalance(HttpCase):
refund = self.env["account.move"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
- "type": "out_refund",
+ "move_type": "out_refund",
"invoice_line_ids": [
(
0,
@@ -193,15 +195,24 @@ class TestAccountTaxBalance(HttpCase):
)
liquidity_account_id = (
self.env["account.account"]
- .search([("internal_type", "=", "liquidity")], limit=1)
+ .search(
+ [
+ ("internal_type", "=", "liquidity"),
+ ("company_id", "=", self.company.id),
+ ],
+ limit=1,
+ )
.id
)
move = self.env["account.move"].create(
{
- "type": "entry",
+ "move_type": "entry",
"date": Date.context_today(self.env.user),
"journal_id": self.env["account.journal"]
- .search([("type", "=", "bank")], limit=1)
+ .search(
+ [("type", "=", "bank"), ("company_id", "=", self.company.id)],
+ limit=1,
+ )
.id,
"name": "Test move",
"line_ids": [
diff --git a/account_tax_balance/views/account_move_view.xml b/account_tax_balance/views/account_move_view.xml
index 2d96548b..39272005 100644
--- a/account_tax_balance/views/account_move_view.xml
+++ b/account_tax_balance/views/account_move_view.xml
@@ -8,7 +8,7 @@
-
+
@@ -18,7 +18,7 @@
-
+
@@ -29,10 +29,10 @@
diff --git a/account_tax_balance/wizard/open_tax_balances.py b/account_tax_balance/wizard/open_tax_balances.py
index 3147641e..a878959a 100644
--- a/account_tax_balance/wizard/open_tax_balances.py
+++ b/account_tax_balance/wizard/open_tax_balances.py
@@ -41,7 +41,7 @@ class WizardOpenTaxBalances(models.TransientModel):
def open_taxes(self):
self.ensure_one()
action = self.env.ref("account_tax_balance.action_tax_balances_tree")
- act_vals = action.read()[0]
+ act_vals = action.sudo().read()[0]
# override action name doesn't work in v12 or v10
# we need to build a dynamic action on main keys
vals = {