Skip to content

Commit

Permalink
[FIX][14.0] assets_management sale
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Feb 13, 2023
1 parent 84b53be commit ed693c2
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions assets_management/wizard/account_move_manage_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,18 @@ def get_dismiss_asset_vals(self):
dismiss_date = self.dismiss_date
digits = self.env["decimal.precision"].precision_get("Account")

max_date = max(asset.depreciation_ids.mapped("last_depreciation_date"))
if max_date and max_date > dismiss_date:
raise ValidationError(
_(
"Cannot dismiss an asset earlier than the last depreciation"
" date.\n"
"(Dismiss date: {}, last depreciation date: {})."
).format(dismiss_date, max_date)
)
last_depreciation_dates = asset.depreciation_ids.filtered(
"last_depreciation_date").mapped("last_depreciation_date")
if last_depreciation_dates:
max_date = max(last_depreciation_dates)
if max_date > dismiss_date:
raise ValidationError(
_(
"Cannot dismiss an asset earlier than the last depreciation"
" date.\n"
"(Dismiss date: {}, last depreciation date: {})."
).format(dismiss_date, max_date)
)

move = self.move_line_ids.mapped("move_id")
move_nums = move.name
Expand Down

0 comments on commit ed693c2

Please sign in to comment.