Skip to content

Commit

Permalink
[MIG] account_cutoff_start_end_dates: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dzungtran89 committed Jan 18, 2023
1 parent da0a0a5 commit 32a1d58
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 78 deletions.
21 changes: 14 additions & 7 deletions account_cutoff_start_end_dates/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Account Cut-off Start End Dates
: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/15.0/account_cutoff_start_end_dates
:target: https://github.com/OCA/account-closing/tree/16.0/account_cutoff_start_end_dates
: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-15-0/account-closing-15-0-account_cutoff_start_end_dates
:target: https://translation.odoo-community.org/projects/account-closing-16-0/account-closing-16-0-account_cutoff_start_end_dates
: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/15.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 @@ -76,7 +76,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_cutoff_start_end_dates%0Aversion:%2015.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_cutoff_start_end_dates%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 @@ -94,6 +94,13 @@ Contributors
* Alexis de Lattre <alexis.delattre@akretion.com>
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Jim Hoefnagels <jim.hoefnagels@dynapps.be>
* `Trobz <https://trobz.com>`_:
* Dzung Tran <dungtd@trobz.com>

Other credits
~~~~~~~~~~~~~

The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp

Maintainers
~~~~~~~~~~~
Expand All @@ -116,6 +123,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-alexis-via|

This module is part of the `OCA/account-closing <https://github.com/OCA/account-closing/tree/15.0/account_cutoff_start_end_dates>`_ project on GitHub.
This module is part of the `OCA/account-closing <https://github.com/OCA/account-closing/tree/16.0/account_cutoff_start_end_dates>`_ 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_cutoff_start_end_dates/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Account Cut-off Start End Dates",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Accounting & Finance",
"license": "AGPL-3",
"summary": "Cutoffs based on start/end dates",
Expand Down
1 change: 1 addition & 0 deletions account_cutoff_start_end_dates/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import account_cutoff
from . import account_cutoff_line
19 changes: 3 additions & 16 deletions account_cutoff_start_end_dates/models/account_cutoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def _get_default_source_journals(self):
default=lambda self: self._get_default_source_journals(),
readonly=True,
states={"draft": [("readonly", False)]},
check_company=True,
)
forecast = fields.Boolean(
readonly=True,
Expand Down Expand Up @@ -96,7 +97,7 @@ def _prepare_date_cutoff_line(self, aml, mapping):
"end_date": aml.end_date,
"account_id": aml.account_id.id,
"cutoff_account_id": cutoff_account_id,
"analytic_account_id": aml.analytic_account_id.id or False,
"analytic_distribution": aml.analytic_distribution,
"total_days": total_days,
"amount": -aml.balance,
"currency_id": self.company_currency_id.id,
Expand Down Expand Up @@ -180,7 +181,7 @@ def get_lines(self):
mapping = self._get_mapping_dict()
domain = [
("journal_id", "in", self.source_journal_ids.ids),
("display_type", "=", False),
("display_type", "not in", ("line_note", "line_section")),
("company_id", "=", self.company_id.id),
("balance", "!=", 0),
]
Expand Down Expand Up @@ -208,17 +209,3 @@ def get_lines(self):
for aml in amls:
line_obj.create(self._prepare_date_cutoff_line(aml, mapping))
return res


class AccountCutoffLine(models.Model):
_inherit = "account.cutoff.line"

start_date = fields.Date(readonly=True)
end_date = fields.Date(readonly=True)
total_days = fields.Integer(readonly=True)
cutoff_days = fields.Integer(
readonly=True,
help="In regular mode, this is the number of days after the "
"cut-off date. In forecast mode, this is the number of days "
"between the start date and the end date.",
)
19 changes: 19 additions & 0 deletions account_cutoff_start_end_dates/models/account_cutoff_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2016-2022 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountCutoffLine(models.Model):
_inherit = "account.cutoff.line"

start_date = fields.Date(readonly=True)
end_date = fields.Date(readonly=True)
total_days = fields.Integer(readonly=True)
cutoff_days = fields.Integer(
readonly=True,
help="In regular mode, this is the number of days after the "
"cut-off date. In forecast mode, this is the number of days "
"between the start date and the end date.",
)
2 changes: 2 additions & 0 deletions account_cutoff_start_end_dates/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Alexis de Lattre <alexis.delattre@akretion.com>
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
* Jim Hoefnagels <jim.hoefnagels@dynapps.be>
* `Trobz <https://trobz.com>`_:
* Dzung Tran <dungtd@trobz.com>
1 change: 1 addition & 0 deletions account_cutoff_start_end_dates/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp
25 changes: 19 additions & 6 deletions account_cutoff_start_end_dates/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>Account Cut-off Start End Dates</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Account Cut-off Start End Dates</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/15.0/account_cutoff_start_end_dates"><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-15-0/account-closing-15-0-account_cutoff_start_end_dates"><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/15.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_cutoff_start_end_dates"><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_cutoff_start_end_dates"><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 allows you to easily compute the prepaid revenue/expenses and also the revenue/expense accruals by using the <strong>Start Date</strong> and <strong>End Date</strong> fields of invoice lines/journal items.</p>
<p>For example, if you have an insurance contrat invoiced in April 2020 that run from April
1st 2020 to March 31st 2021, you will enter these dates as start and end dates
Expand All @@ -387,7 +387,8 @@ <h1 class="title">Account Cut-off Start End Dates</h1>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="id7">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -421,7 +422,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_cutoff_start_end_dates%0Aversion:%2015.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_cutoff_start_end_dates%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 @@ -438,18 +439,30 @@ <h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt;</li>
<li>Jim Hoefnagels &lt;<a class="reference external" href="mailto:jim.hoefnagels&#64;dynapps.be">jim.hoefnagels&#64;dynapps.be</a>&gt;</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://trobz.com">Trobz</a>:</dt>
<dd><ul class="first last">
<li>Dzung Tran &lt;<a class="reference external" href="mailto:dungtd&#64;trobz.com">dungtd&#64;trobz.com</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id7">Other credits</a></h2>
<p>The migration of this module from 15.0 to 16.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<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>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/alexis-via"><img alt="alexis-via" src="https://github.com/alexis-via.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-closing/tree/15.0/account_cutoff_start_end_dates">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_cutoff_start_end_dates">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
78 changes: 36 additions & 42 deletions account_cutoff_start_end_dates/tests/test_account_cutoff_prepaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,46 @@ def setUpClass(cls):
cls.cutoff_model = cls.env["account.cutoff"]
cls.account_model = cls.env["account.account"]
cls.journal_model = cls.env["account.journal"]
cls.account_expense = cls.account_model.search(
[
(
"user_type_id",
"=",
cls.env.ref("account.data_account_type_expenses").id,
),
("company_id", "=", cls.env.ref("base.main_company").id),
],
limit=1,
cls.main_company = cls.env.ref("base.main_company")
cls.account_expense = cls.account_model.create(
{
"account_type": "expense",
"company_id": cls.main_company.id,
"name": "Test expense",
"code": "TE.1",
}
)
cls.account_payable = cls.account_model.search(
[
(
"user_type_id",
"=",
cls.env.ref("account.data_account_type_payable").id,
),
("company_id", "=", cls.env.ref("base.main_company").id),
],
limit=1,
cls.account_payable = cls.account_model.create(
{
"account_type": "liability_payable",
"company_id": cls.main_company.id,
"name": "Test payable",
"code": "TP.1",
}
)
cls.account_cutoff = cls.account_model.search(
[
(
"user_type_id",
"=",
cls.env.ref("account.data_account_type_current_liabilities").id,
),
("company_id", "=", cls.env.ref("base.main_company").id),
],
limit=1,
cls.account_cutoff = cls.account_model.create(
{
"account_type": "liability_current",
"company_id": cls.main_company.id,
"name": "Test cutoff",
"code": "TC.1",
}
)
cls.cutoff_journal = cls.journal_model.search(
[
("company_id", "=", cls.env.ref("base.main_company").id),
("type", "=", "general"),
],
limit=1,
cls.cutoff_journal = cls.journal_model.create(
{
"name": "Cutoff journal",
"type": "general",
"code": "GEN",
"company_id": cls.main_company.id,
}
)
cls.purchase_journal = cls.journal_model.search(
[
("type", "=", "purchase"),
("company_id", "=", cls.env.ref("base.main_company").id),
],
limit=1,
cls.purchase_journal = cls.journal_model.create(
{
"name": "Purchase journal",
"type": "purchase",
"code": "PUR",
"company_id": cls.main_company.id,
}
)

def _date(self, date):
Expand Down
8 changes: 2 additions & 6 deletions account_cutoff_start_end_dates/views/account_cutoff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@
>{'invisible': ['|', '|', ('line_ids', '=', False), ('state', '=', 'done'), ('forecast', '=', True)]}</attribute>
</button>
<field name="cutoff_date" position="after">
<field
name="source_journal_ids"
widget="many2many_tags"
domain="[('company_id', '=', company_id)]"
/>
<field name="source_journal_ids" widget="many2many_tags" />
</field>
</field>
</record>
Expand Down Expand Up @@ -156,7 +152,7 @@
<field name="model">account.cutoff.line</field>
<field name="inherit_id" ref="account_cutoff_base.account_cutoff_line_tree" />
<field name="arch" type="xml">
<field name="analytic_account_id" position="after">
<field name="analytic_distribution" position="after">
<field name="start_date" optional="show" />
<field name="end_date" optional="show" />
<field name="total_days" optional="show" />
Expand Down

0 comments on commit 32a1d58

Please sign in to comment.