[MIG] account_tax_balance: Migration to 14.0

This commit is contained in:
Francisco Ivan Anton Prieto
2020-10-23 15:30:27 +02:00
committed by Borruso
parent 54339092f3
commit 9fbb756b87
13 changed files with 115 additions and 65 deletions

View File

@@ -14,13 +14,13 @@ Tax Balance
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github .. |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 :alt: OCA/account-financial-reporting
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |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 :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |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 :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -49,7 +49,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_. 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. 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 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:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_tax_balance%0Aversion:%2014.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. Do not contact contributors directly about support or help with technical issues.
@@ -73,6 +73,7 @@ Contributors
* Tecnativa - Pedro M. Baeza * Tecnativa - Pedro M. Baeza
* ACSONE SA/NV - Stéphane Bidoul * ACSONE SA/NV - Stéphane Bidoul
* Andrea Stirpe <a.stirpe@onestein.nl> * Andrea Stirpe <a.stirpe@onestein.nl>
* Iván Antón <ozono@ozonomultimedia.com>
Maintainers 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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/13.0/account_tax_balance>`_ project on GitHub. This module is part of the `OCA/account-financial-reporting <https://github.com/OCA/account-financial-reporting/tree/14.0/account_tax_balance>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -6,7 +6,7 @@
{ {
"name": "Tax Balance", "name": "Tax Balance",
"summary": "Compute tax balances based on date range", "summary": "Compute tax balances based on date range",
"version": "13.0.1.0.1", "version": "14.0.1.0.0",
"category": "Invoices & Payments", "category": "Invoices & Payments",
"website": "https://github.com/OCA/account-financial-reporting", "website": "https://github.com/OCA/account-financial-reporting",
"author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, " "author": "Agile Business Group, Therp BV, Tecnativa, ACSONE SA/NV, "
@@ -18,6 +18,7 @@
"wizard/open_tax_balances_view.xml", "wizard/open_tax_balances_view.xml",
"views/account_move_view.xml", "views/account_move_view.xml",
"views/account_tax_view.xml", "views/account_tax_view.xml",
"security/ir.model.access.csv",
], ],
"images": ["images/tax_balance.png"], "images": ["images/tax_balance.png"],
"pre_init_hook": "pre_init_hook", "pre_init_hook": "pre_init_hook",

View File

@@ -7,14 +7,16 @@ from psycopg2 import sql
def pre_init_hook(cr): 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 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 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 important as one move can have move lines on accounts of multiple types
and the move type is set in the order of precedence.""" and the move type is set in the order of precedence."""
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.info("Add account_move.move_type column if it does not yet exist") 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 move_type VARCHAR") cr.execute(
"ALTER TABLE account_move ADD COLUMN IF NOT EXISTS financial_type VARCHAR"
)
MAPPING = [ MAPPING = [
("liquidity", "liquidity", False), ("liquidity", "liquidity", False),
("payable", "payable", "AND aml.balance < 0"), ("payable", "payable", "AND aml.balance < 0"),
@@ -23,22 +25,22 @@ def pre_init_hook(cr):
("receivable_refund", "receivable", "AND aml.balance >= 0"), ("receivable_refund", "receivable", "AND aml.balance >= 0"),
("other", False, False), ("other", False, False),
] ]
for move_type, internal_type, extra_where in MAPPING: for financial_type, internal_type, extra_where in MAPPING:
args = [move_type] args = [financial_type]
query = sql.SQL("UPDATE account_move am SET move_type = %s") query = sql.SQL("UPDATE account_move am SET financial_type = %s")
if internal_type: if internal_type:
query += sql.SQL( query += sql.SQL(
"""FROM account_move_line aml """FROM account_move_line aml
WHERE aml.account_id IN ( WHERE aml.account_id IN (
SELECT id FROM account_account SELECT id FROM account_account
WHERE internal_type = %s) 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) args.append(internal_type)
else: else:
query += sql.SQL("WHERE am.move_type IS NULL") query += sql.SQL("WHERE am.financial_type IS NULL")
if extra_where: if extra_where:
query += sql.SQL(extra_where) query += sql.SQL(extra_where)
cr.execute(query, tuple(args)) 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)

View File

@@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 13.0\n" "Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@@ -86,10 +86,20 @@ msgid "Date Range"
msgstr "" msgstr ""
#. module: account_tax_balance #. 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 #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__display_name
msgid "Display Name" msgid "Display Name"
msgstr "" 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 #. module: account_tax_balance
#: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__from_date #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__from_date
msgid "From Date" msgid "From Date"
@@ -106,13 +116,16 @@ msgid "Has balance in period"
msgstr "" msgstr ""
#. module: account_tax_balance #. 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 #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances__id
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#. module: account_tax_balance #. module: account_tax_balance
#: model:ir.model,name:account_tax_balance.model_account_move #: model:ir.model,name:account_tax_balance.model_account_move
msgid "Journal Entries" msgid "Journal Entry"
msgstr "" msgstr ""
#. module: account_tax_balance #. module: account_tax_balance
@@ -121,6 +134,9 @@ msgid "Journal Item"
msgstr "" msgstr ""
#. module: account_tax_balance #. 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 #: model:ir.model.fields,field_description:account_tax_balance.field_wizard_open_tax_balances____last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "" msgstr ""
@@ -135,11 +151,6 @@ msgstr ""
msgid "Last Updated on" msgid "Last Updated on"
msgstr "" 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 #. module: account_tax_balance
#: model_terms:ir.ui.view,arch_db:account_tax_balance.view_account_move_filter #: model_terms:ir.ui.view,arch_db:account_tax_balance.view_account_move_filter
msgid "Move type" msgid "Move type"

View File

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

View File

@@ -8,7 +8,7 @@ class AccountMove(models.Model):
_inherit = "account.move" _inherit = "account.move"
@api.model @api.model
def _selection_move_type(self): def _selection_financial_type(self):
return [ return [
("other", "Other"), ("other", "Other"),
("liquidity", "Liquidity"), ("liquidity", "Liquidity"),
@@ -18,9 +18,9 @@ class AccountMove(models.Model):
("payable_refund", "Payable refund"), ("payable_refund", "Payable refund"),
] ]
move_type = fields.Selection( financial_type = fields.Selection(
selection="_selection_move_type", selection="_selection_financial_type",
compute="_compute_move_type", compute="_compute_financial_type",
store=True, store=True,
readonly=True, readonly=True,
) )
@@ -30,7 +30,7 @@ class AccountMove(models.Model):
"line_ids.balance", "line_ids.balance",
"line_ids.account_id.user_type_id.type", "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): def _balance_get(line_ids, internal_type):
return sum( return sum(
line_ids.filtered( line_ids.filtered(
@@ -41,12 +41,14 @@ class AccountMove(models.Model):
for move in self: for move in self:
internal_types = move.line_ids.mapped("account_id.internal_type") internal_types = move.line_ids.mapped("account_id.internal_type")
if "liquidity" in internal_types: if "liquidity" in internal_types:
move.move_type = "liquidity" move.financial_type = "liquidity"
elif "payable" in internal_types: elif "payable" in internal_types:
balance = _balance_get(move.line_ids, "payable") 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: elif "receivable" in internal_types:
balance = _balance_get(move.line_ids, "receivable") 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: else:
move.move_type = "other" move.financial_type = "other"

View File

@@ -86,24 +86,24 @@ class AccountTax(models.Model):
def _compute_balance(self): def _compute_balance(self):
for tax in self: for tax in self:
tax.balance_regular = tax.compute_balance( 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.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.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.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.balance = tax.balance_regular + tax.balance_refund
tax.base_balance = tax.base_balance_regular + tax.base_balance_refund tax.base_balance = tax.base_balance_regular + tax.base_balance_refund
def get_target_type_list(self, move_type=None): def get_target_type_list(self, financial_type=None):
if move_type == "refund": if financial_type == "refund":
return ["receivable_refund", "payable_refund"] return ["receivable_refund", "payable_refund"]
elif move_type == "regular": elif financial_type == "regular":
return ["receivable", "payable", "liquidity", "other"] return ["receivable", "payable", "liquidity", "other"]
return [] return []
@@ -123,10 +123,10 @@ class AccountTax(models.Model):
("company_id", "in", company_ids), ("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() self.ensure_one()
domain = self.get_move_lines_domain( 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 # balance is debit - credit whereas on tax return you want to see what
# vat has to be paid so: # vat has to be paid so:
@@ -144,7 +144,7 @@ class AccountTax(models.Model):
("tax_exigible", "=", True), ("tax_exigible", "=", True),
] ]
if type_list: if type_list:
domain.append(("move_id.move_type", "in", type_list)) domain.append(("move_id.financial_type", "in", type_list))
return domain return domain
def get_base_balance_domain(self, state_list, type_list): def get_base_balance_domain(self, state_list, type_list):
@@ -154,13 +154,13 @@ class AccountTax(models.Model):
("tax_exigible", "=", True), ("tax_exigible", "=", True),
] ]
if type_list: if type_list:
domain.append(("move_id.move_type", "in", type_list)) domain.append(("move_id.financial_type", "in", type_list))
return domain 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() from_date, to_date, company_ids, target_move = self.get_context_values()
state_list = self.get_target_state_list(target_move) 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) domain = self.get_move_line_partial_domain(from_date, to_date, company_ids)
balance_domain = [] balance_domain = []
if tax_or_base == "tax": if tax_or_base == "tax":
@@ -170,12 +170,12 @@ class AccountTax(models.Model):
domain.extend(balance_domain) domain.extend(balance_domain)
return 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( 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") action = self.env.ref("account.action_account_moves_all_tree")
vals = action.read()[0] vals = action.sudo().read()[0]
vals["context"] = {} vals["context"] = {}
vals["domain"] = domain vals["domain"] = domain
return vals return vals
@@ -190,16 +190,16 @@ class AccountTax(models.Model):
def view_tax_regular_lines(self): def view_tax_regular_lines(self):
self.ensure_one() 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): def view_base_regular_lines(self):
self.ensure_one() 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): def view_tax_refund_lines(self):
self.ensure_one() 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): def view_base_refund_lines(self):
self.ensure_one() 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")

View File

@@ -4,3 +4,4 @@
* Tecnativa - Pedro M. Baeza * Tecnativa - Pedro M. Baeza
* ACSONE SA/NV - Stéphane Bidoul * ACSONE SA/NV - Stéphane Bidoul
* Andrea Stirpe <a.stirpe@onestein.nl> * Andrea Stirpe <a.stirpe@onestein.nl>
* Iván Antón <ozono@ozonomultimedia.com>

View File

@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_wizard_open_tax_balances_user access_wizard_open_tax_balances model_wizard_open_tax_balances account.group_account_user 1 1 1 1
3 access_wizard_open_tax_balances_manager access_wizard_open_tax_balances model_wizard_open_tax_balances account.group_account_manager 1 1 1 1

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_tax_balance"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-13-0/account-financial-reporting-13-0-account_tax_balance"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/14.0/account_tax_balance"><img alt="OCA/account-financial-reporting" src="https://img.shields.io/badge/github-OCA%2Faccount--financial--reporting-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-financial-reporting-14-0/account-financial-reporting-14-0-account_tax_balance"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/91/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to compute tax balances within a certain date range. <p>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 It depends on date_range module and exposes compute methods that can be called by other modules
(like localization ones).</p> (like localization ones).</p>
@@ -397,7 +397,7 @@ It depends on date_range module and exposes compute methods that can be ca
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_tax_balance%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/account-financial-reporting/issues/new?body=module:%20account_tax_balance%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -420,6 +420,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Tecnativa - Pedro M. Baeza</li> <li>Tecnativa - Pedro M. Baeza</li>
<li>ACSONE SA/NV - Stéphane Bidoul</li> <li>ACSONE SA/NV - Stéphane Bidoul</li>
<li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li> <li>Andrea Stirpe &lt;<a class="reference external" href="mailto:a.stirpe&#64;onestein.nl">a.stirpe&#64;onestein.nl</a>&gt;</li>
<li>Iván Antón &lt;<a class="reference external" href="mailto:ozono&#64;ozonomultimedia.com">ozono&#64;ozonomultimedia.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -429,7 +430,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/13.0/account_tax_balance">OCA/account-financial-reporting</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-financial-reporting/tree/14.0/account_tax_balance">OCA/account-financial-reporting</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -16,8 +16,10 @@ from odoo.tests.common import HttpCase
class TestAccountTaxBalance(HttpCase): class TestAccountTaxBalance(HttpCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.company = self.env.user.company_id
self.range_type = self.env["date.range.type"].create( 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.range_generator = self.env["date.range.generator"]
self.current_year = datetime.now().year self.current_year = datetime.now().year
@@ -69,7 +71,7 @@ class TestAccountTaxBalance(HttpCase):
invoice = self.env["account.move"].create( invoice = self.env["account.move"].create(
{ {
"partner_id": self.env.ref("base.res_partner_2").id, "partner_id": self.env.ref("base.res_partner_2").id,
"type": "out_invoice", "move_type": "out_invoice",
"invoice_line_ids": [ "invoice_line_ids": [
( (
0, 0,
@@ -152,7 +154,7 @@ class TestAccountTaxBalance(HttpCase):
refund = self.env["account.move"].create( refund = self.env["account.move"].create(
{ {
"partner_id": self.env.ref("base.res_partner_2").id, "partner_id": self.env.ref("base.res_partner_2").id,
"type": "out_refund", "move_type": "out_refund",
"invoice_line_ids": [ "invoice_line_ids": [
( (
0, 0,
@@ -193,15 +195,24 @@ class TestAccountTaxBalance(HttpCase):
) )
liquidity_account_id = ( liquidity_account_id = (
self.env["account.account"] self.env["account.account"]
.search([("internal_type", "=", "liquidity")], limit=1) .search(
[
("internal_type", "=", "liquidity"),
("company_id", "=", self.company.id),
],
limit=1,
)
.id .id
) )
move = self.env["account.move"].create( move = self.env["account.move"].create(
{ {
"type": "entry", "move_type": "entry",
"date": Date.context_today(self.env.user), "date": Date.context_today(self.env.user),
"journal_id": self.env["account.journal"] "journal_id": self.env["account.journal"]
.search([("type", "=", "bank")], limit=1) .search(
[("type", "=", "bank"), ("company_id", "=", self.company.id)],
limit=1,
)
.id, .id,
"name": "Test move", "name": "Test move",
"line_ids": [ "line_ids": [

View File

@@ -8,7 +8,7 @@
<field name="inherit_id" ref="account.view_move_tree" /> <field name="inherit_id" ref="account.view_move_tree" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="state" position="after"> <field name="state" position="after">
<field name="move_type" /> <field name="financial_type" />
</field> </field>
</field> </field>
</record> </record>
@@ -18,7 +18,7 @@
<field name="inherit_id" ref="account.view_move_form" /> <field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="ref" position="after"> <field name="ref" position="after">
<field name="move_type" /> <field name="financial_type" />
</field> </field>
</field> </field>
</record> </record>
@@ -29,10 +29,10 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<group expand="0" position="inside"> <group expand="0" position="inside">
<filter <filter
name="move_type" name="financial_type"
string="Move type" string="Move type"
domain="[]" domain="[]"
context="{'group_by':'move_type'}" context="{'group_by':'financial_type'}"
/> />
</group> </group>
</field> </field>

View File

@@ -41,7 +41,7 @@ class WizardOpenTaxBalances(models.TransientModel):
def open_taxes(self): def open_taxes(self):
self.ensure_one() self.ensure_one()
action = self.env.ref("account_tax_balance.action_tax_balances_tree") 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 # override action name doesn't work in v12 or v10
# we need to build a dynamic action on main keys # we need to build a dynamic action on main keys
vals = { vals = {