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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
from datetime import datetime, timedelta, date
from dateutil import parser
from dateutil import rrule
from dateutil.relativedelta import relativedelta
from openerp.osv import fields, osv
from openerp.service import web_services
from openerp.tools.translate import _
import pytz
import re
import time
import logging
from openerp import tools, SUPERUSER_ID
_logger = logging.getLogger(__name__)
class bank_statement(osv.osv):
_name = 'account.bank.statement.recalc'
# _inherit = 'procurement.order'
_description = 'Kalkulasi ulang saldo Bank Statement'
# _inherit = 'res.alarm'
__attribute__ = {}
_columns = {
'name' : fields.char('Reference'),
'backdated_statement_id': fields.many2one('account.bank.statement', 'Bank Statement Reference', select=True),
}
_defaults = {}
def do_run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \
context=None):
_logger.info("Start Scheduler Recalculate Backdated Transaction")
cr.execute("select a.id, a.name, a.balance_start, a.total_entry_encoding, a.balance_end, a.date"
" from account_bank_statement a "
" where a.state = 'confirm' "
" order by a.date asc, id asc")
#datas = cr.fetchall()
datas = cr.dictfetchall()
print 'datas ', datas
idx = 0
tmp_balance_start=0
for rows in datas:
if idx == 0:
balance_start = rows['balance_start']
if rows['balance_start'] > 0 :
balance_start = 0
else:
balance_start = tmp_balance_start
print 'balance_start : %s ' % balance_start
balance_end = balance_start + rows['total_entry_encoding']
print 'balance_start : %s ' % balance_start
#print "update account_bank_statement set balance_start = %s, balance_end= %s, balance_end_real= %s where id = %s " % (balance_start, balance_end, rows['id'])
cr.execute("update account_bank_statement "
" set balance_start = %s, "
" balance_end= %s, "
" balance_end_real= %s "
" where id = %s " % (balance_start, balance_end, balance_end, rows['id']))
idx += 1
tmp_balance_start = balance_end
_logger.info("End Scheduler Recalculate Backdated Transaction")
return True
bank_statement()
|