Skip to content

Commit 29231d4

Browse files
fredzamoabgalexis-via
authored andcommitted
[MIG] account_cutoff_start_end_dates: added pre_init_hook to handle migration
1 parent 220b27b commit 29231d4

File tree

5 files changed

+47
-125
lines changed

5 files changed

+47
-125
lines changed
+1-124
Original file line numberDiff line numberDiff line change
@@ -1,124 +1 @@
1-
=======================
2-
Account Cut-off Prepaid
3-
=======================
4-
5-
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6-
!! This file is generated by oca-gen-addon-readme !!
7-
!! changes will be overwritten. !!
8-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9-
10-
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11-
:target: https://odoo-community.org/page/development-status
12-
:alt: Beta
13-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14-
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15-
:alt: License: AGPL-3
16-
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--closing-lightgray.png?logo=github
17-
:target: https://github.com/OCA/account-closing/tree/13.0/account_cutoff_prepaid
18-
:alt: OCA/account-closing
19-
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/account-closing-13-0/account-closing-13-0-account_cutoff_prepaid
21-
:alt: Translate me on Weblate
22-
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/89/13.0
24-
:alt: Try me on Runbot
25-
26-
|badge1| |badge2| |badge3| |badge4| |badge5|
27-
28-
This module allows you to easily compute the prepaid revenue and prepaid expenses and to generate the related cutoff journal items. It uses the **Start Date** and **End Date** fields of journal entries (copied from the same fields of invoice lines).
29-
30-
For
31-
example, if you have an insurance contrat for your company that run from April
32-
1st 2013 to March 31st 2014, you will enter these dates as start and end dates
33-
on the supplier invoice line. If your fiscal year ends on December 31st 2013,
34-
3 months of expenses are part of the 2014 fiscal year and should not be part of
35-
the 2013 fiscal year. So, thanks to this module, you will create a *Prepaid
36-
Expense* on December 31st 2013 and OpenERP will identify this expense with the
37-
3 months that are after the cut-off date and propose to generate the
38-
appropriate cut-off journal entry.
39-
40-
**Table of contents**
41-
42-
.. contents::
43-
:local:
44-
45-
Configuration
46-
=============
47-
48-
On the form view of the company, in the *Configuration* tab, there is a *Cut-offs* section where you can configure:
49-
50-
* the *Default Cut-off Journal*, which is the journal in which the cut-off journal items will be generated by default,
51-
* the *Default Account for Prepaid Revenue*,
52-
* the *Default Account for Prepaid Expense*.
53-
54-
Usage
55-
=====
56-
57-
To compute the prepaid revenue, go to the menu *Accounting > Cut-offs
58-
> Prepaid Revenue* and click on the *Create* button. Enter the cut-off
59-
date, check that the source journals contains all your sale journals
60-
and click on the button *Re-Generate lines*: Odoo will scan all the
61-
journal entries of the source journals and will get all the lines that
62-
have an end date after the cut-off date and, for each line, it will
63-
compute the prepaid revenue. If you agree with the result, click on the
64-
button *Create Journal Entry*: Odoo will generate an account move at the
65-
cut-off date to cut these prepaid revenue. Hint: you can then use the reversal
66-
feature to generate the reverse journal items on the next day.
67-
68-
If you need to answer a question such as *How much revenue did I already
69-
invoice for my next fiscal year ?*, you will be interested by the
70-
*forecast* feature. For that, on the Prepaid Revenue form, click on
71-
the *Forecast* option and you will see 2 new fields: *Start Date* and
72-
*End Date*. Enter the start date and the end date of your next fiscal
73-
year and click on the button *Re-Generate lines*: you will see all the
74-
revenue that you already have in your source journals for that period.
75-
76-
Bug Tracker
77-
===========
78-
79-
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-closing/issues>`_.
80-
In case of trouble, please check there if your issue has already been reported.
81-
If you spotted it first, help us smashing it by providing a detailed and welcomed
82-
`feedback <https://github.com/OCA/account-closing/issues/new?body=module:%20account_cutoff_prepaid%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
83-
84-
Do not contact contributors directly about support or help with technical issues.
85-
86-
Credits
87-
=======
88-
89-
Authors
90-
~~~~~~~
91-
92-
* Akretion
93-
94-
Contributors
95-
~~~~~~~~~~~~
96-
97-
* Alexis de Lattre <alexis.delattre@akretion.com>
98-
* Stéphane Bidoul <stephane.bidoul@acsone.eu>
99-
* Jim Hoefnagels <jim.hoefnagels@dynapps.be>
100-
101-
Maintainers
102-
~~~~~~~~~~~
103-
104-
This module is maintained by the OCA.
105-
106-
.. image:: https://odoo-community.org/logo.png
107-
:alt: Odoo Community Association
108-
:target: https://odoo-community.org
109-
110-
OCA, or the Odoo Community Association, is a nonprofit organization whose
111-
mission is to support the collaborative development of Odoo features and
112-
promote its widespread use.
113-
114-
.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px
115-
:target: https://github.com/alexis-via
116-
:alt: alexis-via
117-
118-
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
119-
120-
|maintainer-alexis-via|
121-
122-
This module is part of the `OCA/account-closing <https://github.com/OCA/account-closing/tree/13.0/account_cutoff_prepaid>`_ project on GitHub.
123-
124-
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1+
Will be regenerated from readme subdir
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from . import models
2+
from .hooks import module_migration

account_cutoff_start_end_dates/__manifest__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
55

66
{
7-
"name": "Account Cut-off Prepaid",
7+
"name": "Account Cut-off Start End Dates",
88
"version": "14.0.1.0.0",
99
"category": "Accounting & Finance",
1010
"license": "AGPL-3",
@@ -13,6 +13,7 @@
1313
"maintainers": ["alexis-via"],
1414
"website": "https://github.com/OCA/account-closing",
1515
"depends": ["account_cutoff_base", "account_invoice_start_end_dates"],
16+
"external_dependencies": {"python": ["openupgradelib"]},
1617
"data": ["views/account_cutoff.xml"],
1718
"images": [
1819
"images/prepaid_revenue_draft.jpg",
@@ -21,4 +22,5 @@
2122
],
2223
"installable": True,
2324
"application": True,
25+
"pre_init_hook": "module_migration",
2426
}
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 Alfredo Zamora - Agile Business Group
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
from odoo import SUPERUSER_ID, api
7+
8+
9+
def module_migration(cr):
10+
account_cutoff_line_model = "account.cutoff.line"
11+
account_cutoff_line_table = "account_cutoff_line"
12+
account_cutoff_prepaid = "account_cutoff_prepaid"
13+
account_cutoff_accrual_dates = "account_cutoff_accrual_dates"
14+
account_cutoff_start_end_dates = "account_cutoff_start_end_dates"
15+
if openupgrade.is_module_installed(cr, account_cutoff_accrual_dates):
16+
openupgrade.update_module_names(
17+
cr,
18+
[
19+
(account_cutoff_accrual_dates, account_cutoff_start_end_dates),
20+
],
21+
merge_modules=True,
22+
)
23+
if openupgrade.is_module_installed(cr, account_cutoff_prepaid):
24+
openupgrade.update_module_names(
25+
cr,
26+
[
27+
(account_cutoff_prepaid, account_cutoff_start_end_dates),
28+
],
29+
merge_modules=True,
30+
)
31+
field_renames = [
32+
(
33+
account_cutoff_line_model,
34+
account_cutoff_line_table,
35+
"prepaid_days",
36+
"cutoff_days",
37+
),
38+
]
39+
env = api.Environment(cr, SUPERUSER_ID, {})
40+
openupgrade.rename_fields(env, field_renames)

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# generated from manifests external_dependencies
2+
openupgradelib

0 commit comments

Comments
 (0)