[FIX] account_asset: use newest depreciation date for new depreciations
The code uses self.depreciation_line_ids[0] and incorrectly assumes it is always the latest (newest) depreciation line. This sorts the recordset to guarantee that this is true. opw-678678
This commit is contained in:
@@ -160,7 +160,7 @@ class AccountAssetAsset(models.Model):
|
||||
def compute_depreciation_board(self):
|
||||
self.ensure_one()
|
||||
|
||||
posted_depreciation_line_ids = self.depreciation_line_ids.filtered(lambda x: x.move_check)
|
||||
posted_depreciation_line_ids = self.depreciation_line_ids.filtered(lambda x: x.move_check).sorted(key=lambda l: l.depreciation_date, reverse=True)
|
||||
unposted_depreciation_line_ids = self.depreciation_line_ids.filtered(lambda x: not x.move_check)
|
||||
|
||||
# Remove old unposted depreciation lines. We cannot use unlink() with One2many field
|
||||
|
||||
Reference in New Issue
Block a user