-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_it_asset_management: Max depreciable amount
- Loading branch information
1 parent
d3b41a5
commit 1294353
Showing
8 changed files
with
126 additions
and
21 deletions.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Author(s): Silvio Gregorini ([email protected]) | ||
# Copyright 2019 Openforce Srls Unipersonale (www.openforce.it) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import asset_compute_depreciable_amount | ||
|
||
from . import account_account | ||
from . import account_fiscal_year | ||
from . import account_journal | ||
|
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
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 |
---|---|---|
@@ -1,20 +1,16 @@ | ||
# Author(s): Silvio Gregorini ([email protected]) | ||
# Copyright 2019 Openforce Srls Unipersonale (www.openforce.it) | ||
# Copyright 2024 Simone Rubino - Aion Tech | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AssetCategoryDepreciationType(models.Model): | ||
_name = "asset.category.depreciation.type" | ||
_inherit = "l10n_it_asset_management.compute.depreciable_amount" | ||
_description = "Asset Category - Depreciation Type" | ||
|
||
base_coeff = fields.Float( | ||
default=1, | ||
help="Coeff to compute depreciable amount from purchase amount", | ||
string="Dep Base Coeff", | ||
) | ||
|
||
category_id = fields.Many2one( | ||
"asset.category", | ||
ondelete="cascade", | ||
|
@@ -46,8 +42,9 @@ class AssetCategoryDepreciationType(models.Model): | |
def get_depreciation_vals(self, amount_depreciable=0): | ||
self.ensure_one() | ||
return { | ||
"amount_depreciable": amount_depreciable * self.base_coeff, | ||
"amount_depreciable": self._get_depreciable_amount(amount_depreciable), | ||
"base_coeff": self.base_coeff, | ||
"base_max_amount": self.base_max_amount, | ||
"mode_id": self.mode_id.id, | ||
"percentage": self.percentage, | ||
"pro_rata_temporis": self.pro_rata_temporis, | ||
|
28 changes: 28 additions & 0 deletions
28
l10n_it_asset_management/models/asset_compute_depreciable_amount.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,28 @@ | ||
# Copyright 2024 Simone Rubino - Aion Tech | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AssetComputeDepreciableAmount(models.AbstractModel): | ||
_name = "l10n_it_asset_management.compute.depreciable_amount" | ||
_description = "Compute depreciable amount" | ||
|
||
base_coeff = fields.Float( | ||
default=1, | ||
help="Coeff to compute depreciable amount from purchase amount", | ||
string="Dep Base Coeff", | ||
) | ||
base_max_amount = fields.Float( | ||
string="Maximum depreciable amount", | ||
) | ||
|
||
def _get_depreciable_amount(self, base_amount): | ||
"""Compute how much of `base_amount` can be depreciated.""" | ||
self.ensure_one() | ||
depreciable_amount = base_amount | ||
if self.base_coeff: | ||
depreciable_amount = base_amount * self.base_coeff | ||
if self.base_max_amount: | ||
depreciable_amount = min(depreciable_amount, self.base_max_amount) | ||
return depreciable_amount |
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
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
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
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