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 Jun 14, 2023
1 parent 3ba05cc commit b05e291
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 67 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
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 {
"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
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ def setUpClass(cls, chart_template_ref=None):
super().setUpClass()
cls.account_model = cls.env["account.account"]
cls.move_line_obj = cls.env["account.move.line"]
cls.account_type_rec = cls.env.ref("account.data_account_type_receivable")
cls.account_type_pay = cls.env.ref("account.data_account_type_payable")
cls.account_type_rev = cls.env.ref("account.data_account_type_revenue")
cls.account_type_exp = cls.env.ref("account.data_account_type_expenses")
cls.account_type_ass = cls.env.ref("account.data_account_type_current_assets")
cls.account_type_liq = cls.env.ref("account.data_account_type_liquidity")
cls.account_type_lia = cls.env.ref(
"account.data_account_type_current_liabilities"
)
cls.account_type_rec = "asset_receivable"
cls.account_type_pay = "liability_payable"
cls.account_type_rev = "income"
cls.account_type_exp = "expense"
cls.account_type_ass = "asset_current"
cls.account_type_liq = "asset_cash"
cls.account_type_lia = "liability_current"

cls.account_user = cls.env.user
account_manager = cls.env["res.users"].create(
Expand All @@ -51,49 +49,49 @@ def setUpClass(cls, chart_template_ref=None):

cls.a_sale = cls.account_model.create(
{
"code": "reve_acc",
"code": "reve.acc",
"name": "revenue account",
"user_type_id": cls.account_type_rev.id,
"account_type": cls.account_type_rev,
"reconcile": False,
}
)
cls.a_purchase = cls.account_model.create(
{
"code": "expe_acc",
"code": "expe.acc",
"name": "expense account",
"user_type_id": cls.account_type_exp.id,
"account_type": cls.account_type_exp,
"reconcile": False,
}
)
cls.a_debit_vat = cls.account_model.create(
{
"code": "debvat_acc",
"code": "debvat.cc",
"name": "debit vat account",
"user_type_id": cls.account_type_ass.id,
"account_type": cls.account_type_ass,
"reconcile": False,
}
)
cls.a_credit_vat = cls.account_model.create(
{
"code": "credvat_acc",
"code": "credvat.acc",
"name": "credit vat account",
"user_type_id": cls.account_type_lia.id,
"account_type": cls.account_type_lia,
"reconcile": False,
}
)
cls.a_pf_closing = cls.account_model.create(
{
"code": "pf_acc",
"code": "pf.acc",
"name": "profit&loss account",
"user_type_id": cls.account_type_ass.id,
"account_type": cls.account_type_ass,
"reconcile": False,
}
)
cls.a_bal_closing = cls.account_model.create(
{
"code": "bal_acc",
"code": "bal.acc",
"name": "financial closing account",
"user_type_id": cls.account_type_lia.id,
"account_type": cls.account_type_lia,
"reconcile": False,
}
)
Expand All @@ -115,8 +113,8 @@ def setUpClass(cls, chart_template_ref=None):
0,
{
"value": "balance",
"days": 15,
"option": "after_invoice_month",
"days_after": 15,
"end_month": True,
},
),
],
Expand Down Expand Up @@ -218,48 +216,55 @@ def test_account_closing(self):
)

move_lines = self.move_line_obj.search([])
user_type_names = move_lines.mapped("account_id.user_type_id.name")
account_types = move_lines.mapped("account_id.account_type")
self.assertTrue(
(
[
x
for x in user_type_names
for x in account_types
if x
not in [
"Receivable",
"Current Assets",
"Income",
"Payable",
"Current Liabilities",
"Expenses",
"Bank and Cash",
"asset_receivable", # Receivable
"asset_current", # Current Assets
"income", # Current Assets
"liability_payable", # Payable
"liability_current", # Current Liabilities
"expense", # Expenses
"asset_cash", # Bank and Cash
]
]
== []
),
"There are account user types not defined!",
)

# Receivable
rec_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Receivable")]
[("account_id.account_type", "=", "asset_receivable")]
)
# Payable
pay_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Payable")]
[("account_id.account_type", "=", "liability_payable")]
)
# Income
inc_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Income")]
[("account_id.account_type", "=", "income")]
)
# Expenses
exp_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Expenses")]
[("account_id.account_type", "=", "expense")]
)
# Current Assets
cas_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Current Assets")]
[("account_id.account_type", "=", "asset_current")]
)
# Current Liabilities
cli_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Current Liabilities")]
[("account_id.account_type", "=", "liability_current")]
)
# Bank and Cash
bac_move_lines = self.move_line_obj.search(
[("account_id.user_type_id.name", "=", "Bank and Cash")]
[("account_id.account_type", "=", "asset_cash")]
)

rec_accounts = rec_move_lines.mapped("account_id.code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<record id="view_account_fiscalyear_closing_template_tree" model="ir.ui.view">
<field name="model">account.fiscalyear.closing.template</field>
<field name="arch" type="xml">
<tree string="Fiscal year closing">
<tree>
<field name="name" />
<field name="company_id" groups="base.group_multi_company" />
<field name="move_config_ids" />
Expand Down Expand Up @@ -81,7 +81,7 @@
<group>
<field name="closing_type_ids" nolabel="1">
<tree editable="bottom">
<field name="account_type_id" />
<field name="account_type" />
<field name="closing_type" />
</tree>
</field>
Expand Down
Loading

0 comments on commit b05e291

Please sign in to comment.