Skip to content
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

[IMP] Specificare un conto nell'ammortamento del cespite diverso dal conto nella categoria #4166

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions l10n_it_asset_management/models/asset_depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,51 @@ class AssetDepreciation(models.Model):

zero_depreciation_until = fields.Date(string="Zero Depreciation Up To")

depreciation_account_id = fields.Many2one(
comodel_name="account.account",
compute="_compute_depreciation_account_id",
readonly=False,
store=True,
string="Depreciation Account",
)
gain_account_id = fields.Many2one(
comodel_name="account.account",
compute="_compute_gain_account_id",
readonly=False,
store=True,
string="Capital Gain Account",
)
loss_account_id = fields.Many2one(
comodel_name="account.account",
compute="_compute_loss_account_id",
readonly=False,
store=True,
string="Capital Loss Account",
)

@api.depends(
"asset_id.category_id",
)
def _compute_depreciation_account_id(self):
for dep in self:
dep.depreciation_account_id = (
dep.asset_id.category_id.depreciation_account_id
)

@api.depends(
"asset_id.category_id",
)
def _compute_gain_account_id(self):
for dep in self:
dep.gain_account_id = dep.asset_id.category_id.gain_account_id

@api.depends(
"asset_id.category_id",
)
def _compute_loss_account_id(self):
for dep in self:
dep.loss_account_id = dep.asset_id.category_id.loss_account_id

@api.model_create_multi
def create(self, vals_list):
depreciations = self.browse()
Expand Down
6 changes: 3 additions & 3 deletions l10n_it_asset_management/models/asset_depreciation_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def get_depreciated_account_move_line_vals(self):
# Asset depreciation
if not self.partial_dismissal:
credit_account_id = self.asset_id.category_id.fund_account_id.id
debit_account_id = self.asset_id.category_id.depreciation_account_id.id
debit_account_id = self.depreciation_id.depreciation_account_id.id

# Asset partial dismissal
else:
Expand All @@ -427,7 +427,7 @@ def get_depreciated_account_move_line_vals(self):
def get_gain_account_move_line_vals(self):
self.ensure_one()
credit_line_vals = {
"account_id": self.asset_id.category_id.gain_account_id.id,
"account_id": self.depreciation_id.gain_account_id.id,
"credit": self.amount,
"debit": 0.0,
"currency_id": self.currency_id.id,
Expand Down Expand Up @@ -462,7 +462,7 @@ def get_loss_account_move_line_vals(self):
"name": " - ".join((self.asset_id.make_name(), self.name)),
}
debit_line_vals = {
"account_id": self.asset_id.category_id.loss_account_id.id,
"account_id": self.depreciation_id.loss_account_id.id,
"credit": 0.0,
"debit": self.amount,
"currency_id": self.currency_id.id,
Expand Down
1 change: 1 addition & 0 deletions l10n_it_asset_management/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_assets_management
from . import test_asset_depreciation
Loading
Loading