[FIX] account_asset_management: include 'number' method_time

This commit is contained in:
mreficent
2021-04-19 13:04:19 +02:00
parent 5e0215d678
commit a4bedab0df
3 changed files with 44 additions and 10 deletions

View File

@@ -211,7 +211,9 @@ class AccountAsset(models.Model):
help="Choose the method to use to compute the dates and "
"number of depreciation lines.\n"
" * Number of Years: Specify the number of years "
"for the depreciation.\n",
"for the depreciation.\n"
" * Number of Depreciations: Fix the number of "
"depreciation lines and the time between 2 depreciations.\n",
)
days_calc = fields.Boolean(
string="Calculate by days",
@@ -395,10 +397,12 @@ class AccountAsset(models.Model):
_("Degressive-Linear is only supported for Time Method = Year.")
)
@api.constrains("date_start", "method_end", "method_time")
@api.constrains("date_start", "method_end", "method_number", "method_time")
def _check_dates(self):
if self.filtered(
lambda a: a.method_time == "end" and a.method_end <= a.date_start
lambda a: a.method_time == "year"
and not a.method_number
and a.method_end <= a.date_start
):
raise UserError(_("The Start Date must precede the Ending Date."))