diff options
| author | Joren Van Onder <jov@odoo.com> | 2016-05-27 13:10:18 +0200 |
|---|---|---|
| committer | Joren Van Onder <jov@odoo.com> | 2016-05-27 13:51:56 +0200 |
| commit | 9499b5d4d2481f79226ddbcf1e66176ce216b6fc (patch) | |
| tree | 7f7606535bfd38e9026d0583ded44e30a4fbc51e | |
| parent | 82b9d7d51133a2b0510092c823ba7b6db4f9b565 (diff) | |
[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
| -rw-r--r-- | addons/account_asset/account_asset.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/account_asset/account_asset.py b/addons/account_asset/account_asset.py index 7e53f0ff4c1..aef5666277c 100644 --- a/addons/account_asset/account_asset.py +++ b/addons/account_asset/account_asset.py @@ -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 |
