[FIX] Create function search domain asset lines

This commit is contained in:
newtratip
2023-10-16 16:51:14 +07:00
committed by ps-tubtim
parent db6733913f
commit 5fe3b4b215

View File

@@ -1203,6 +1203,15 @@ class AccountAsset(models.Model):
"""use this method to customise the name of the accounting entry"""
return (self.code or str(self.id)) + "/" + str(seq)
def _get_asset_line_domain(self, date_end):
return [
("asset_id", "in", self.ids),
("type", "=", "depreciate"),
("init_entry", "=", False),
("line_date", "<=", date_end),
("move_check", "=", False),
]
def _compute_entries(self, date_end, check_triggers=False):
# TODO : add ir_cron job calling this method to
# generate periodical accounting entries
@@ -1218,13 +1227,7 @@ class AccountAsset(models.Model):
asset.compute_depreciation_board()
depreciations = self.env["account.asset.line"].search(
[
("asset_id", "in", self.ids),
("type", "=", "depreciate"),
("init_entry", "=", False),
("line_date", "<=", date_end),
("move_check", "=", False),
],
self._get_asset_line_domain(date_end),
order="line_date",
)
for depreciation in depreciations: