-
-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.0][MIG] account_asset_management_method_number_end : Migration to v11 #704
Closed
grindtildeath
wants to merge
8
commits into
OCA:11.0
from
grindtildeath:11.0-mig-account_asset_management_method_number_end
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b1e944b
[10.0][MIG]account_asset_management suite refactoring + 10.0 port
luc-demeyer bd71f93
Fix tests on account_asset_management_xls and account_asset_managemen…
grindtildeath 11e9343
[MIG] account_asset_management_method_number_end : Migration to 11.0
grindtildeath d7f8022
Improvements according to review
grindtildeath e4f5ef7
Split readme into parts
grindtildeath 9f456a7
Move from TransactionCase to SavepointCase
grindtildeath 4a4246d
Drop migrations
grindtildeath fa896ca
Extract common fields to mixin
grindtildeath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png | ||
:target: https://www.gnu.org/licenses/agpl | ||
:alt: License: AGPL-3 | ||
|
||
================================================ | ||
Financial asset management - method Number & End | ||
================================================ | ||
|
||
This module enables the Time Methods 'Number of Depreciations' and 'Ending Date' for the Financial Assets. | ||
|
||
By doing so, you can use the depreciation table calculation and posting functionality | ||
for e.g. Cost/Revenue spreading purposes. | ||
|
||
Usage | ||
===== | ||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/92/10.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/OCA/account-financial-tools/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. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
- Luc De Meyer (Noviat) | ||
|
||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
15 changes: 15 additions & 0 deletions
15
account_asset_management_method_number_end/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2009-2018 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Financial asset management - method Number & End', | ||
'version': '11.0.1.0.0', | ||
'license': 'AGPL-3', | ||
'author': "Noviat,Odoo Community Association (OCA)", | ||
'website': 'https://github.com/OCA/account-financial-tools', | ||
'category': 'Accounting & Finance', | ||
'depends': [ | ||
'account_asset_management', | ||
], | ||
'installable': True, | ||
} |
3 changes: 3 additions & 0 deletions
3
account_asset_management_method_number_end/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import account_asset_method_number_end | ||
from . import account_asset | ||
from . import account_asset_profile |
10 changes: 10 additions & 0 deletions
10
account_asset_management_method_number_end/models/account_asset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2009-2018 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountAsset(models.Model): | ||
|
||
_name = 'account.asset' | ||
_inherit = ['account.asset', 'account.asset.method.number.end.mixin'] |
30 changes: 30 additions & 0 deletions
30
account_asset_management_method_number_end/models/account_asset_method_number_end.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2018 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import models, fields | ||
|
||
|
||
class AccountAssetMethodNumberEnd(models.AbstractModel): | ||
|
||
_name = 'account.asset.method.number.end.mixin' | ||
|
||
method_number = fields.Integer( | ||
string='Number', | ||
help="The meaning of this parameter depends on the Time Method.\n" | ||
" * Number of Years: Specify the number of years " | ||
"for the depreciation.\n" | ||
" * Number of Depreciations: Fix the number of " | ||
"depreciation lines and the time between 2 depreciations.\n" | ||
" * Ending Date: Choose the time between 2 depreciations " | ||
"and the date the depreciations won't go beyond.") | ||
|
||
method_time = fields.Selection( | ||
selection=lambda self: self.env[ | ||
'account.asset.profile']._selection_method_time(), | ||
help="Choose the method to use to compute the dates and " | ||
"number of depreciation lines.\n" | ||
" * Number of Years: Specify the number of years " | ||
"for the depreciation.\n" | ||
" * Number of Depreciations: Fix the number of " | ||
"depreciation lines and the time between 2 depreciations.\n" | ||
" * Ending Date: Choose the time between 2 depreciations " | ||
"and the date the depreciations won't go beyond.") |
20 changes: 20 additions & 0 deletions
20
account_asset_management_method_number_end/models/account_asset_profile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2009-2018 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, models, _ | ||
|
||
|
||
class AccountAssetProfile(models.Model): | ||
|
||
_name = 'account.asset.profile' | ||
_inherit = [ | ||
'account.asset.profile', 'account.asset.method.number.end.mixin' | ||
] | ||
|
||
@api.model | ||
def _selection_method_time(self): | ||
res = super(AccountAssetProfile, self)._selection_method_time() | ||
res += [ | ||
('number', _('Number of Depreciations')), | ||
('end', _('Ending Date'))] | ||
return res |
2 changes: 2 additions & 0 deletions
2
account_asset_management_method_number_end/readme/CONTRIBUTORS.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Luc De Meyer (Noviat) | ||
* Akim Juillerat <akim.juillerat@camptocamp.com> |
4 changes: 4 additions & 0 deletions
4
account_asset_management_method_number_end/readme/DESCRIPTION.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This module enables the Time Methods 'Number of Depreciations' and 'Ending Date' for the Financial Assets. | ||
|
||
By doing so, you can use the depreciation table calculation and posting functionality | ||
for e.g. Cost/Revenue spreading purposes. |
Binary file added
BIN
+9.23 KB
account_asset_management_method_number_end/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_account_asset_management |
79 changes: 79 additions & 0 deletions
79
account_asset_management_method_number_end/tests/test_account_asset_management.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright 2009-2018 Noviat. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import time | ||
|
||
from odoo.tests.common import SavepointCase | ||
from odoo import tools | ||
from odoo.modules.module import get_resource_path | ||
|
||
|
||
class TestAssetManagement(SavepointCase): | ||
|
||
@classmethod | ||
def _load(cls, module, *args): | ||
tools.convert_file(cls.cr, module, | ||
get_resource_path(module, *args), | ||
{}, 'init', False, 'test', | ||
cls.registry._assertion_report) | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
super(TestAssetManagement, cls).setUpClass() | ||
|
||
cls._load('account', 'test', 'account_minimal_test.xml') | ||
cls._load('account_asset_management', 'tests', | ||
'account_asset_test_data.xml') | ||
|
||
cls.asset_model = cls.env['account.asset'] | ||
cls.dl_model = cls.env['account.asset.line'] | ||
|
||
def test_1_linear_number(self): | ||
"""Linear with Method Time 'Number'.""" | ||
asset = self.asset_model.create({ | ||
'name': 'test asset', | ||
'profile_id': self.ref('account_asset_management.' | ||
'account_asset_profile_car_5Y'), | ||
'purchase_value': 1000, | ||
'salvage_value': 0, | ||
'date_start': time.strftime('%Y-07-07'), | ||
'method_time': 'number', | ||
'method': 'linear', | ||
'method_number': 12, | ||
'method_period': 'month', | ||
'prorata': True, | ||
}) | ||
asset.compute_depreciation_board() | ||
asset.refresh() | ||
|
||
# check values in the depreciation board | ||
self.assertEqual(len(asset.depreciation_line_ids), 13) | ||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, | ||
83.33, places=2) | ||
self.assertAlmostEqual(asset.depreciation_line_ids[-1].amount, | ||
83.37, places=2) | ||
|
||
def test_2_linear_end(self): | ||
"""Linear with Method Time End Date.""" | ||
asset = self.asset_model.create({ | ||
'name': 'test asset', | ||
'profile_id': self.ref('account_asset_management.' | ||
'account_asset_profile_car_5Y'), | ||
'purchase_value': 1000, | ||
'salvage_value': 0, | ||
'date_start': time.strftime('%Y-01-30'), | ||
'method_time': 'end', | ||
'method': 'linear', | ||
'method_end': time.strftime('%Y-06-30'), | ||
'method_period': 'month', | ||
'prorata': True, | ||
}) | ||
asset.compute_depreciation_board() | ||
asset.refresh() | ||
|
||
# check values in the depreciation board | ||
self.assertEqual(len(asset.depreciation_line_ids), 7) | ||
self.assertAlmostEqual(asset.depreciation_line_ids[1].amount, | ||
166.67, places=2) | ||
self.assertAlmostEqual(asset.depreciation_line_ids[-1].amount, | ||
166.65, places=2) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.