1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
from odoo import models, fields, api
from odoo.exceptions import UserError
class UpdateDepreciationMoveWizard(models.TransientModel):
_name = 'update.depreciation.move.wizard'
_description = 'Wizard untuk Update Move Check Depreciation Line'
target_date = fields.Date(string="Tanggal Depresiasi", required=True)
# def action_update_move_check(self):
# lines = self.env['account.asset.depreciation.line'].search([
# ('depreciation_date', '=', self.target_date),
# ])
# if not lines:
# raise UserError("Tidak ada baris depresiasi dengan tanggal tersebut.")
# updated_count = 0
# for line in lines:
# if not line.move_check:
# line.move_check = True
# line.move_posted_check = True
# updated_count += 1
# return {
# 'type': 'ir.actions.client',
# 'tag': 'display_notification',
# 'params': {
# 'title': 'Update Selesai',
# 'message': f'{updated_count} baris berhasil di-update.',
# 'type': 'success',
# 'sticky': False,
# }
# }
def action_update_move_check(self):
assets = self.env['account.asset.asset']
assets.compute_generated_entries(self.target_date)
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'params': {
'title': 'Update Selesai',
'message': 'Depresiasi berhasil di-update.',
'type': 'success',
'sticky': False,
}
}
|