Skip to content

Commit

Permalink
[MIG] account_fiscal_year_closing: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Borruso committed Oct 6, 2023
1 parent 0c9d5ea commit 92f8abb
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 72 deletions.
15 changes: 8 additions & 7 deletions account_fiscal_year_closing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Fiscal year closing
: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--closing-lightgray.png?logo=github
:target: https://github.com/OCA/account-closing/tree/14.0/account_fiscal_year_closing
:target: https://github.com/OCA/account-closing/tree/16.0/account_fiscal_year_closing
:alt: OCA/account-closing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing
:target: https://translation.odoo-community.org/projects/account-closing-16-0/account-closing-16-0-account_fiscal_year_closing
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/89/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/account-closing&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Expand Down Expand Up @@ -104,7 +104,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-closing/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-closing/issues/new?body=module:%20account_fiscal_year_closing%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-closing/issues/new?body=module:%20account_fiscal_year_closing%0Aversion:%2016.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.

Expand All @@ -126,6 +126,7 @@ Contributors
* `CorporateHub <https://corporatehub.eu/>`__

* Alexey Pelykh <alexey.pelykh@corphub.eu>
* Giuseppe Borruso <gborruso@dinamicheaziendali.it>

Maintainers
~~~~~~~~~~~
Expand All @@ -140,6 +141,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-closing <https://github.com/OCA/account-closing/tree/14.0/account_fiscal_year_closing>`_ project on GitHub.
This module is part of the `OCA/account-closing <https://github.com/OCA/account-closing/tree/16.0/account_fiscal_year_closing>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion account_fiscal_year_closing/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Fiscal year closing",
"summary": "Generic fiscal year closing wizard",
"version": "14.0.1.0.1",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"website": "https://github.com/OCA/account-closing",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
58 changes: 58 additions & 0 deletions account_fiscal_year_closing/migrations/16.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2023 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def update_account_type(env, model, new_type, old_type):
openupgrade.logged_query(
env.cr,
"""
UPDATE %(model)s
SET account_type = '%(new_type)s'
WHERE id in (
SELECT id
WHERE account_type_id = %(old_type)s
)
"""
% {
"model": model,
"new_type": new_type,
"old_type": old_type,
},
)


@openupgrade.migrate()
def migrate(env, version):

all_account_type = [
("asset_receivable", env("account.data_account_type_receivable").id),
("asset_cash", env("account.data_account_type_liquidity").id),
("asset_current", env("account.data_account_type_current_assets").id),
("asset_non_current", env("account.data_account_type_non_current_assets").id),
("asset_fixed", env("account.data_account_type_fixed_assets").id),
("expense", env("account.data_account_type_expenses").id),
("expense_depreciation", env("account.data_account_type_depreciation").id),
("expense_direct_cost", env("account.data_account_type_direct_costs").id),
("off_balance", env("account.data_account_off_sheet").id),
("liability_payable", env("account.data_account_type_payable").id),
("liability_credit_card", env("account.data_account_type_credit_card").id),
("asset_prepayments", env("account.data_account_type_prepayments").id),
("liability_current", env("account.data_account_type_current_liabilities").id),
(
"liability_non_current",
env("account.data_account_type_non_current_liabilities").id,
),
("equity", env("account.data_account_type_equity").id),
("equity_unaffected", env("account.data_unaffected_earnings").id),
("income", env("account.data_account_type_revenue").id),
("income_other", env("account.data_account_type_other_income").id),
]

for new_type, old_type in all_account_type:
update_account_type(
env, "account_fiscalyear_closing_type_template", new_type, old_type
)
update_account_type(env, "account_fiscalyear_closing_type", new_type, old_type)
18 changes: 9 additions & 9 deletions account_fiscal_year_closing/models/account_fiscalyear_closing.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def _default_company_id(self):
("posted", "Posted"),
("cancelled", "Cancelled"),
],
string="State",
readonly=True,
default="draft",
)
Expand Down Expand Up @@ -150,7 +149,7 @@ def _prepare_mapping(self, tmpl_mapping):
@api.model
def _prepare_type(self, tmpl_type):
return {

Check warning on line 151 in account_fiscal_year_closing/models/account_fiscalyear_closing.py

View check run for this annotation

Codecov / codecov/patch

account_fiscal_year_closing/models/account_fiscalyear_closing.py#L151

Added line #L151 was not covered by tests
"account_type_id": tmpl_type.account_type_id,
"account_type": tmpl_type.account_type,
"closing_type": tmpl_type.closing_type,
}

Expand Down Expand Up @@ -387,7 +386,7 @@ class AccountFiscalyearClosingConfig(models.Model):
string="Closing types",
)
date = fields.Date(string="Move date")
enabled = fields.Boolean(string="Enabled", default=True)
enabled = fields.Boolean(default=True)
journal_id = fields.Many2one(required=True)
move_id = fields.Many2one(comodel_name="account.move", string="Move")

Expand Down Expand Up @@ -416,7 +415,7 @@ def closing_type_get(self, account):
self.ensure_one()
closing_type = self.closing_type_default
closing_types = self.closing_type_ids.filtered(
lambda r: r.account_type_id == account.user_type_id
lambda r: r.account_type == account.account_type
)
if closing_types:
closing_type = closing_types[0].closing_type

Check warning on line 421 in account_fiscal_year_closing/models/account_fiscalyear_closing.py

View check run for this annotation

Codecov / codecov/patch

account_fiscal_year_closing/models/account_fiscalyear_closing.py#L421

Added line #L421 was not covered by tests
Expand Down Expand Up @@ -551,11 +550,12 @@ class AccountFiscalyearClosingMapping(models.Model):
string="Destination account",
)

@api.model
def create(self, vals):
if "dest_account_id" in vals:
vals["dest_account_id"] = vals["dest_account_id"][0]
res = super(AccountFiscalyearClosingMapping, self).create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if "dest_account_id" in vals:
vals["dest_account_id"] = vals["dest_account_id"][0]
res = super(AccountFiscalyearClosingMapping, self).create(vals_list)
return res

def write(self, vals):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AccountFiscalyearClosingConfigAbstract(models.AbstractModel):
_order = "sequence asc, id asc"

name = fields.Char(string="Description", required=True)
sequence = fields.Integer(string="Sequence", index=True, default=1)
sequence = fields.Integer(index=True, default=1)
code = fields.Char(string="Unique code", required=True)
inverse = fields.Char(
string="Inverse config",
Expand Down Expand Up @@ -81,8 +81,27 @@ class AccountFiscalyearClosingTypeAbstract(models.AbstractModel):
required=True,
default="unreconciled",
)
account_type_id = fields.Many2one(
comodel_name="account.account.type",
string="Account type",
account_type = fields.Selection(
selection=[
("asset_receivable", "Receivable"),
("asset_cash", "Bank and Cash"),
("asset_current", "Current Assets"),
("asset_non_current", "Non-current Assets"),
("asset_prepayments", "Prepayments"),
("asset_fixed", "Fixed Assets"),
("liability_payable", "Payable"),
("liability_credit_card", "Credit Card"),
("liability_current", "Current Liabilities"),
("liability_non_current", "Non-current Liabilities"),
("equity", "Equity"),
("equity_unaffected", "Current Year Earnings"),
("income", "Income"),
("income_other", "Other Income"),
("expense", "Expenses"),
("expense_depreciation", "Depreciation"),
("expense_direct_cost", "Cost of Revenue"),
("off_balance", "Off-Balance Sheet"),
],
string="Type",
required=True,
)
1 change: 1 addition & 0 deletions account_fiscal_year_closing/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* `CorporateHub <https://corporatehub.eu/>`__

* Alexey Pelykh <alexey.pelykh@corphub.eu>
* Giuseppe Borruso <gborruso@dinamicheaziendali.it>
9 changes: 5 additions & 4 deletions account_fiscal_year_closing/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Fiscal year closing</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Fiscal year closing</h1>
!! This file is generated by oca-gen-addon-readme !!
!! 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-closing/tree/14.0/account_fiscal_year_closing"><img alt="OCA/account-closing" src="https://img.shields.io/badge/github-OCA%2Faccount--closing-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing"><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/89/14.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-closing/tree/16.0/account_fiscal_year_closing"><img alt="OCA/account-closing" src="https://img.shields.io/badge/github-OCA%2Faccount--closing-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-closing-16-0/account-closing-16-0-account_fiscal_year_closing"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/webui/builds.html?repo=OCA/account-closing&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module implements a generic fiscal year closing system for those
countries where closing/opening moves or other kind of closing operations are
mandatory in accounting books.</p>
Expand Down Expand Up @@ -453,7 +453,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-closing/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-closing/issues/new?body=module:%20account_fiscal_year_closing%0Aversion:%2014.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-closing/issues/new?body=module:%20account_fiscal_year_closing%0Aversion:%2016.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>
</div>
<div class="section" id="credits">
Expand All @@ -475,6 +475,7 @@ <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<li>Alexey Pelykh &lt;<a class="reference external" href="mailto:alexey.pelykh&#64;corphub.eu">alexey.pelykh&#64;corphub.eu</a>&gt;</li>
</ul>
</li>
<li>Giuseppe Borruso &lt;<a class="reference external" href="mailto:gborruso&#64;dinamicheaziendali.it">gborruso&#64;dinamicheaziendali.it</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -484,7 +485,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-closing/tree/14.0/account_fiscal_year_closing">OCA/account-closing</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-closing/tree/16.0/account_fiscal_year_closing">OCA/account-closing</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>
</div>
</div>
Expand Down
Loading

0 comments on commit 92f8abb

Please sign in to comment.