From e47d942a436d7955b06cc4f278681d61b910263a Mon Sep 17 00:00:00 2001 From: Simone Rubino Date: Fri, 1 Mar 2024 13:00:51 +0100 Subject: [PATCH] [REF] assets_management: Repo template update --- l10n_it_asset_management/models/account_move.py | 2 +- l10n_it_asset_management/models/asset.py | 2 +- .../models/asset_depreciation.py | 3 ++- .../models/asset_depreciation_line.py | 6 +++--- .../models/asset_depreciation_mode_line.py | 2 +- l10n_it_asset_management/report/asset_journal.py | 13 ++++++++----- .../report/asset_previsional.py | 15 +++++++++------ .../tests/test_assets_management.py | 5 +++-- .../wizard/account_move_manage_asset.py | 9 ++++++--- 9 files changed, 34 insertions(+), 23 deletions(-) diff --git a/l10n_it_asset_management/models/account_move.py b/l10n_it_asset_management/models/account_move.py index 3db2a825dbe..6f13756a851 100644 --- a/l10n_it_asset_management/models/account_move.py +++ b/l10n_it_asset_management/models/account_move.py @@ -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( diff --git a/l10n_it_asset_management/models/asset.py b/l10n_it_asset_management/models/asset.py index 92b6833f260..949605621e6 100644 --- a/l10n_it_asset_management/models/asset.py +++ b/l10n_it_asset_management/models/asset.py @@ -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 = _( diff --git a/l10n_it_asset_management/models/asset_depreciation.py b/l10n_it_asset_management/models/asset_depreciation.py index 4249bcba253..994d50671c2 100644 --- a/l10n_it_asset_management/models/asset_depreciation.py +++ b/l10n_it_asset_management/models/asset_depreciation.py @@ -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, ) ) diff --git a/l10n_it_asset_management/models/asset_depreciation_line.py b/l10n_it_asset_management/models/asset_depreciation_line.py index c9e96eaff03..40296df2b19 100644 --- a/l10n_it_asset_management/models/asset_depreciation_line.py +++ b/l10n_it_asset_management/models/asset_depreciation_line.py @@ -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): @@ -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() @@ -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() diff --git a/l10n_it_asset_management/models/asset_depreciation_mode_line.py b/l10n_it_asset_management/models/asset_depreciation_mode_line.py index 5aa4d664a18..55474f8c992 100644 --- a/l10n_it_asset_management/models/asset_depreciation_mode_line.py +++ b/l10n_it_asset_management/models/asset_depreciation_mode_line.py @@ -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 diff --git a/l10n_it_asset_management/report/asset_journal.py b/l10n_it_asset_management/report/asset_journal.py index 9220c5a603b..f00a7ece325 100644 --- a/l10n_it_asset_management/report/asset_journal.py +++ b/l10n_it_asset_management/report/asset_journal.py @@ -727,7 +727,8 @@ 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 ) ] ) @@ -735,13 +736,14 @@ 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 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 @@ -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]: @@ -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 = { diff --git a/l10n_it_asset_management/report/asset_previsional.py b/l10n_it_asset_management/report/asset_previsional.py index b152dffb27f..efe2d0e9aab 100644 --- a/l10n_it_asset_management/report/asset_previsional.py +++ b/l10n_it_asset_management/report/asset_previsional.py @@ -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() @@ -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): @@ -796,7 +796,8 @@ 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 ) ] ) @@ -804,13 +805,14 @@ 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 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 @@ -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]: diff --git a/l10n_it_asset_management/tests/test_assets_management.py b/l10n_it_asset_management/tests/test_assets_management.py index e037f36fe0f..4a62c4bb4a1 100644 --- a/l10n_it_asset_management/tests/test_assets_management.py +++ b/l10n_it_asset_management/tests/test_assets_management.py @@ -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() diff --git a/l10n_it_asset_management/wizard/account_move_manage_asset.py b/l10n_it_asset_management/wizard/account_move_manage_asset.py index 338cc369f2d..62150241786 100644 --- a/l10n_it_asset_management/wizard/account_move_manage_asset.py +++ b/l10n_it_asset_management/wizard/account_move_manage_asset.py @@ -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" @@ -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,