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

[14.0][FIX] assets_management get only not null dates #3346

Merged
Merged
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
22 changes: 13 additions & 9 deletions assets_management/wizard/account_move_manage_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,19 @@
fund_amt = self.depreciated_fund_amount
purchase_amt = self.asset_purchase_amount

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(

Check warning on line 516 in assets_management/wizard/account_move_manage_asset.py

View check run for this annotation

Codecov / codecov/patch

assets_management/wizard/account_move_manage_asset.py#L516

Added line #L516 was not covered by tests
"last_depreciation_date"
).mapped("last_depreciation_date")
if last_depreciation_dates:
max_date = max(last_depreciation_dates)

Check warning on line 520 in assets_management/wizard/account_move_manage_asset.py

View check run for this annotation

Codecov / codecov/patch

assets_management/wizard/account_move_manage_asset.py#L520

Added line #L520 was not covered by tests
if max_date > dismiss_date:
raise ValidationError(

Check warning on line 522 in assets_management/wizard/account_move_manage_asset.py

View check run for this annotation

Codecov / codecov/patch

assets_management/wizard/account_move_manage_asset.py#L522

Added line #L522 was not covered by tests
_(
"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