Skip to content

Commit

Permalink
[REF] assets_management: Repo template update
Browse files Browse the repository at this point in the history
  • Loading branch information
SirAionTech committed Mar 1, 2024
1 parent e9933d0 commit e47d942
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion l10n_it_asset_management/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def button_cancel(self):
dep_lines = aa_infos.mapped("dep_line_id")
aa_infos.unlink()
# Filtering needed: cannot delete dep lines with a.a.info
dep_lines.filtered(lambda l: not l.asset_accounting_info_ids).unlink()
dep_lines.filtered(lambda line: not line.asset_accounting_info_ids).unlink()
return res

@api.depends(
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_asset_management/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def onchange_purchase_amount(self):
for dep in self.depreciation_ids:
dep.amount_depreciable = self.purchase_amount * dep.base_coeff
if self.depreciation_ids.mapped("line_ids").filtered(
lambda l: l.move_type == "depreciated"
lambda line: line.move_type == "depreciated"
):
title = _("Warning!")
msg = _(
Expand Down
3 changes: 2 additions & 1 deletion l10n_it_asset_management/models/asset_depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ def check_before_generate_depreciation_lines(self, dep_date):
raise ValidationError(
_(
"Cannot update the following assets which contain"
" draft depreciation for the chosen date and types:\n%(draft_names)s",
" draft depreciation for the"
" chosen date and types:\n%(draft_names)s",
draft_names=draft_names,
)
)
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 @@ -343,7 +343,7 @@ def button_remove_account_move(self):
self.mapped("move_id").unlink()

def generate_account_move(self):
for line in self.filtered(lambda l: l.needs_account_move()):
for line in self.filtered(lambda line: line.needs_account_move()):
line.generate_account_move_single()

def generate_account_move_single(self):
Expand Down Expand Up @@ -480,7 +480,7 @@ def post_dismiss_asset(self):
dep.ensure_one()
types = ("gain", "loss")
gain_or_loss = self.filtered(
lambda l: l.needs_account_move() and l.move_type in types
lambda line: line.needs_account_move() and line.move_type in types
)
if gain_or_loss:
gain_or_loss.generate_account_move_single()
Expand All @@ -491,7 +491,7 @@ def post_partial_dismiss_asset(self):
dep.ensure_one()
types = ("depreciated", "gain", "loss")
to_create_move = self.filtered(
lambda l: l.needs_account_move() and l.move_type in types
lambda line: line.needs_account_move() and line.move_type in types
)
if to_create_move:
to_create_move.generate_account_move()
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_depreciation_amount_multiplier(self):
return multiplier

lines = self.filtered(
lambda l: l.from_nr <= nr and (not l.to_nr or l.to_nr >= nr)
lambda line: line.from_nr <= nr and (not line.to_nr or line.to_nr >= nr)
)
if not lines:
return multiplier
Expand Down
13 changes: 8 additions & 5 deletions l10n_it_asset_management/report/asset_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,21 +727,23 @@ def get_report_dep_line_year_data(self):
[
line.amount
for line in self.dep_line_ids.filtered(
lambda l: l.move_type == "depreciated" and not l.partial_dismissal
lambda line: line.move_type == "depreciated"
and not line.partial_dismissal
)
]
)
amount_dismissal = sum(
[
line.amount
for line in self.dep_line_ids.filtered(
lambda l: l.move_type == "depreciated" and l.partial_dismissal
lambda line: line.move_type == "depreciated"
and line.partial_dismissal
)
]
)

prev_year_line = report_dep.report_depreciation_year_line_ids.filtered(
lambda l: l.sequence == self.sequence - 1
lambda line: line.sequence == self.sequence - 1
)
asset = self.report_depreciation_id.report_asset_id.asset_id
fy_start = self.fiscal_year_id.date_from
Expand Down Expand Up @@ -797,7 +799,8 @@ def get_report_dep_line_year_data(self):

type_mapping = {"in": {}, "out": {}}
for dep_line in self.dep_line_ids.filtered(
lambda l: l.move_type in ("in", "out") and l.depreciation_line_type_id
lambda line: line.move_type in ("in", "out")
and line.depreciation_line_type_id
):
dep_type = dep_line.depreciation_line_type_id
if dep_type not in type_mapping[dep_line.move_type]:
Expand Down Expand Up @@ -825,7 +828,7 @@ def get_report_dep_line_year_data(self):

accounting_doc_vals = []
for dep_line in self.dep_line_ids.filtered(
lambda l: l.move_type in ("in", "out")
lambda line: line.move_type in ("in", "out")
):
for num, aa_info in enumerate(dep_line.asset_accounting_info_ids):
vals = {
Expand Down
15 changes: 9 additions & 6 deletions l10n_it_asset_management/report/asset_previsional.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ class ReportDepreciationLineByYear(models.TransientModel):
type_name = fields.Char()

def clean_unused(self):
self.filtered(lambda l: l.do_clean()).unlink()
self.filtered(lambda line: line.do_clean()).unlink()

def do_clean(self):
self.ensure_one()
Expand All @@ -725,7 +725,7 @@ def do_clean(self):
):
previous_line = (
self.report_depreciation_id.report_depreciation_year_line_ids.filtered(
lambda l: l.sequence == self.sequence - 1
lambda line: line.sequence == self.sequence - 1
)
)
if float_is_zero(previous_line.amount_residual, digits):
Expand Down Expand Up @@ -796,21 +796,23 @@ def get_report_dep_line_year_data(self):
[
line.amount
for line in self.dep_line_ids.filtered(
lambda l: l.move_type == "depreciated" and not l.partial_dismissal
lambda line: line.move_type == "depreciated"
and not line.partial_dismissal
)
]
)
amount_dismissal = sum(
[
line.amount
for line in self.dep_line_ids.filtered(
lambda l: l.move_type == "depreciated" and l.partial_dismissal
lambda line: line.move_type == "depreciated"
and line.partial_dismissal
)
]
)

prev_year_line = report_dep.report_depreciation_year_line_ids.filtered(
lambda l: l.sequence == self.sequence - 1
lambda line: line.sequence == self.sequence - 1
)
asset = self.report_depreciation_id.report_asset_id.asset_id
fy_start = self.fiscal_year_id.date_from
Expand Down Expand Up @@ -866,7 +868,8 @@ def get_report_dep_line_year_data(self):

type_mapping = {"in": {}, "out": {}}
for dep_line in self.dep_line_ids.filtered(
lambda l: l.move_type in ("in", "out") and l.depreciation_line_type_id
lambda line: line.move_type in ("in", "out")
and line.depreciation_line_type_id
):
dep_type = dep_line.depreciation_line_type_id
if dep_type not in type_mapping[dep_line.move_type]:
Expand Down
5 changes: 3 additions & 2 deletions l10n_it_asset_management/tests/test_assets_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ def test_00_create_asset_depreciate_and_sale(self):
self.assertEqual(
exc.exception.args[0],
"Cannot dismiss an asset earlier than the last depreciation date.\n"
"(Dismiss date: %s, last depreciation date: %s)."
% (today, second_depreciation_date),
"(Dismiss date: {}, last depreciation date: {}).".format(
today, second_depreciation_date
),
)
sale_invoice.button_cancel()
sale_invoice.button_draft()
Expand Down
9 changes: 6 additions & 3 deletions l10n_it_asset_management/wizard/account_move_manage_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ def get_update_asset_vals(self):
if sign < 0 and float_compare(residual, amount, digits) < 0:
raise ValidationError(
_(
"Could not update `%(asset_name)s`: not enough residual amount"
"Could not update `%(asset_name)s`:"
" not enough residual amount"
" to write off move `%(move_num)s`.\n"
"(Amount to write off: %(amount)s;"
" residual amount: %(residual)s.)\n"
Expand Down Expand Up @@ -714,9 +715,11 @@ def get_update_asset_vals(self):
if balances < 0 and residual + balances < 0:
raise ValidationError(
_(
"Could not update `%(asset_name)s`: not enough residual amount to"
"Could not update `%(asset_name)s`:"
" not enough residual amount to"
" write off.\n"
"(Amount to write off: %(balances)s; residual amount: %(residual)s.)\n"
"(Amount to write off: %(balances)s;"
" residual amount: %(residual)s.)\n"
"Maybe you should try to dismiss this asset instead?",
asset_name=asset_name,
balances=balances,
Expand Down

0 comments on commit e47d942

Please sign in to comment.