e0a316ae2a1825b7d0c22da7d700ac8bb0f28c92
[odoo/odoo.git] / addons / account / account_bank_statement.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 import time
23 import netsvc
24 from osv import fields, osv
25
26 from tools.misc import currency
27 from tools.translate import _
28
29 class account_bank_statement(osv.osv):
30     def _default_journal_id(self, cr, uid, context={}):
31         if context.get('journal_id', False):
32             return context['journal_id']
33         return False
34
35     def _default_balance_start(self, cr, uid, context={}):
36         cr.execute('select id from account_bank_statement where journal_id=%s order by date desc limit 1', (1,))
37         res = cr.fetchone()
38         if res:
39             return self.browse(cr, uid, [res[0]], context)[0].balance_end
40         return 0.0
41
42     def _end_balance(self, cursor, user, ids, name, attr, context=None):
43         res_currency_obj = self.pool.get('res.currency')
44         res_users_obj = self.pool.get('res.users')
45
46         res = {}
47
48         company_currency_id = res_users_obj.browse(cursor, user, user,
49                 context=context).company_id.currency_id.id
50
51         statements = self.browse(cursor, user, ids, context=context)
52         for statement in statements:
53             res[statement.id] = statement.balance_start
54             currency_id = statement.currency.id
55             for line in statement.move_line_ids:
56                 if line.debit > 0:
57                     if line.account_id.id == \
58                             statement.journal_id.default_debit_account_id.id:
59                         res[statement.id] += res_currency_obj.compute(cursor,
60                                 user, company_currency_id, currency_id,
61                                 line.debit, context=context)
62                 else:
63                     if line.account_id.id == \
64                             statement.journal_id.default_credit_account_id.id:
65                         res[statement.id] -= res_currency_obj.compute(cursor,
66                                 user, company_currency_id, currency_id,
67                                 line.credit, context=context)
68             if statement.state == 'draft':
69                 for line in statement.line_ids:
70                     res[statement.id] += line.amount
71         for r in res:
72             res[r] = round(res[r], 2)
73         return res
74
75     def _get_period(self, cr, uid, context={}):
76         periods = self.pool.get('account.period').find(cr, uid)
77         if periods:
78             return periods[0]
79         else:
80             return False
81
82     def _currency(self, cursor, user, ids, name, args, context=None):
83         res = {}
84         res_currency_obj = self.pool.get('res.currency')
85         res_users_obj = self.pool.get('res.users')
86         default_currency = res_users_obj.browse(cursor, user,
87                 user, context=context).company_id.currency_id
88         for statement in self.browse(cursor, user, ids, context=context):
89             currency = statement.journal_id.currency
90             if not currency:
91                 currency = default_currency
92             res[statement.id] = currency.id
93         currency_names = {}
94         for currency_id, currency_name in res_currency_obj.name_get(cursor,
95                 user, [x for x in res.values()], context=context):
96             currency_names[currency_id] = currency_name
97         for statement_id in res.keys():
98             currency_id = res[statement_id]
99             res[statement_id] = (currency_id, currency_names[currency_id])
100         return res
101
102     _order = "date desc"
103     _name = "account.bank.statement"
104     _description = "Bank Statement"
105     _columns = {
106         'name': fields.char('Name', size=64, required=True, states={'confirm': [('readonly', True)]}),
107         'date': fields.date('Date', required=True,
108             states={'confirm': [('readonly', True)]}),
109         'journal_id': fields.many2one('account.journal', 'Journal', required=True,
110             states={'confirm': [('readonly', True)]}, domain=[('type', '=', 'cash')]),
111         'period_id': fields.many2one('account.period', 'Period', required=True,
112             states={'confirm':[('readonly', True)]}),
113         'balance_start': fields.float('Starting Balance', digits=(16,2),
114             states={'confirm':[('readonly',True)]}),
115         'balance_end_real': fields.float('Ending Balance', digits=(16,2),
116             states={'confirm':[('readonly', True)]}),
117         'balance_end': fields.function(_end_balance, method=True, string='Balance'),
118         'line_ids': fields.one2many('account.bank.statement.line',
119             'statement_id', 'Statement lines',
120             states={'confirm':[('readonly', True)]}),
121         'move_line_ids': fields.one2many('account.move.line', 'statement_id',
122             'Entry lines', states={'confirm':[('readonly',True)]}),
123         'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirmed')],
124             'State', required=True,
125             states={'confirm': [('readonly', True)]}, readonly="1",
126             help='When new statement is created the state will be \'Draft\'. \
127             \n* And after getting confirmation from the bank it will be in \'Confirmed\' state.'),
128         'currency': fields.function(_currency, method=True, string='Currency',
129             type='many2one', relation='res.currency'),
130     }
131
132     _defaults = {
133         'name': lambda self, cr, uid, context=None: \
134                 self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement'),
135         'date': lambda *a: time.strftime('%Y-%m-%d'),
136         'state': lambda *a: 'draft',
137         'balance_start': _default_balance_start,
138         'journal_id': _default_journal_id,
139         'period_id': _get_period,
140     }
141
142     def button_confirm(self, cr, uid, ids, context={}):
143         done = []
144         res_currency_obj = self.pool.get('res.currency')
145         res_users_obj = self.pool.get('res.users')
146         account_move_obj = self.pool.get('account.move')
147         account_move_line_obj = self.pool.get('account.move.line')
148         account_bank_statement_line_obj = \
149                 self.pool.get('account.bank.statement.line')
150
151         company_currency_id = res_users_obj.browse(cr, uid, uid,
152                 context=context).company_id.currency_id.id
153
154         for st in self.browse(cr, uid, ids, context):
155             if not st.state=='draft':
156                 continue
157
158             if not (abs((st.balance_end or 0.0) - st.balance_end_real) < 0.0001):
159                 raise osv.except_osv(_('Error !'),
160                         _('The statement balance is incorrect !\n') +
161                         _('The expected balance (%.2f) is different than the computed one. (%.2f)') % (st.balance_end_real, st.balance_end))
162             if (not st.journal_id.default_credit_account_id) \
163                     or (not st.journal_id.default_debit_account_id):
164                 raise osv.except_osv(_('Configuration Error !'),
165                         _('Please verify that an account is defined in the journal.'))
166
167             for line in st.move_line_ids:
168                 if line.state <> 'valid':
169                     raise osv.except_osv(_('Error !'),
170                             _('The account entries lines are not in valid state.'))
171             # for bank.statement.lines
172             # In line we get reconcile_id on bank.ste.rec.
173             # in bank stat.rec we get line_new_ids on bank.stat.rec.line
174             for move in st.line_ids:
175                 context.update({'date':move.date})
176                 move_id = account_move_obj.create(cr, uid, {
177                     'journal_id': st.journal_id.id,
178                     'period_id': st.period_id.id,
179                     'date': move.date,
180                 }, context=context)
181                 account_bank_statement_line_obj.write(cr, uid, [move.id], {
182                     'move_ids': [(4,move_id, False)]
183                 })
184                 if not move.amount:
185                     continue
186
187                 torec = []
188                 if move.amount >= 0:
189                     account_id = st.journal_id.default_credit_account_id.id
190                 else:
191                     account_id = st.journal_id.default_debit_account_id.id
192                 acc_cur = ((move.amount<=0) and st.journal_id.default_debit_account_id) or move.account_id
193                 amount = res_currency_obj.compute(cr, uid, st.currency.id,
194                         company_currency_id, move.amount, context=context,
195                         account=acc_cur)
196                 if move.reconcile_id and move.reconcile_id.line_new_ids:
197                     for newline in move.reconcile_id.line_new_ids:
198                         amount += newline.amount
199
200                 val = {
201                     'name': move.name,
202                     'date': move.date,
203                     'ref': move.ref,
204                     'move_id': move_id,
205                     'partner_id': ((move.partner_id) and move.partner_id.id) or False,
206                     'account_id': (move.account_id) and move.account_id.id,
207                     'credit': ((amount>0) and amount) or 0.0,
208                     'debit': ((amount<0) and -amount) or 0.0,
209                     'statement_id': st.id,
210                     'journal_id': st.journal_id.id,
211                     'period_id': st.period_id.id,
212                     'currency_id': st.currency.id,
213                 }
214
215                 amount = res_currency_obj.compute(cr, uid, st.currency.id,
216                         company_currency_id, move.amount, context=context,
217                         account=acc_cur)
218                 if st.currency.id <> company_currency_id:
219                     amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
220                                 st.currency.id, amount, context=context,
221                                 account=acc_cur)
222                     val['amount_currency'] = -amount_cur
223
224                 if move.account_id and move.account_id.currency_id and move.account_id.currency_id.id <> company_currency_id:
225                     val['currency_id'] = move.account_id.currency_id.id
226                     if company_currency_id==move.account_id.currency_id.id:
227                         amount_cur = move.amount
228                     else:
229                         amount_cur = res_currency_obj.compute(cr, uid, company_currency_id,
230                                 move.account_id.currency_id.id, amount, context=context,
231                                 account=acc_cur)
232                     val['amount_currency'] = amount_cur
233
234                 torec.append(account_move_line_obj.create(cr, uid, val , context=context))
235
236                 if move.reconcile_id and move.reconcile_id.line_new_ids:
237                     for newline in move.reconcile_id.line_new_ids:
238                         account_move_line_obj.create(cr, uid, {
239                             'name': newline.name or move.name,
240                             'date': move.date,
241                             'ref': move.ref,
242                             'move_id': move_id,
243                             'partner_id': ((move.partner_id) and move.partner_id.id) or False,
244                             'account_id': (newline.account_id) and newline.account_id.id,
245                             'debit': newline.amount>0 and newline.amount or 0.0,
246                             'credit': newline.amount<0 and -newline.amount or 0.0,
247                             'statement_id': st.id,
248                             'journal_id': st.journal_id.id,
249                             'period_id': st.period_id.id,
250                             'analytic_account_id':newline.analytic_id and newline.analytic_id.id or False,
251
252                         }, context=context)
253
254                 # Fill the secondary amount/currency
255                 # if currency is not the same than the company
256                 amount_currency = False
257                 currency_id = False
258                 if st.currency.id <> company_currency_id:
259                     amount_currency = move.amount
260                     currency_id = st.currency.id
261                 account_move_line_obj.create(cr, uid, {
262                     'name': move.name,
263                     'date': move.date,
264                     'ref': move.ref,
265                     'move_id': move_id,
266                     'partner_id': ((move.partner_id) and move.partner_id.id) or False,
267                     'account_id': account_id,
268                     'credit': ((amount < 0) and -amount) or 0.0,
269                     'debit': ((amount > 0) and amount) or 0.0,
270                     'statement_id': st.id,
271                     'journal_id': st.journal_id.id,
272                     'period_id': st.period_id.id,
273                     'amount_currency': amount_currency,
274                     'currency_id': currency_id,
275                     }, context=context)
276
277                 for line in account_move_line_obj.browse(cr, uid, [x.id for x in
278                         account_move_obj.browse(cr, uid, move_id,
279                             context=context).line_id],
280                         context=context):
281                     if line.state <> 'valid':
282                         raise osv.except_osv(_('Error !'),
283                                 _('Ledger Posting line "%s" is not valid') % line.name)
284
285                 if move.reconcile_id and move.reconcile_id.line_ids:
286                     torec += map(lambda x: x.id, move.reconcile_id.line_ids)
287                     #try:
288                     if abs(move.reconcile_amount-move.amount)<0.0001:
289
290                         writeoff_acc_id = False
291                         #There should only be one write-off account!
292                         for entry in move.reconcile_id.line_new_ids:
293                             writeoff_acc_id = entry.account_id.id
294                             break
295
296                         account_move_line_obj.reconcile(cr, uid, torec, 'statement', writeoff_acc_id=writeoff_acc_id, writeoff_period_id=st.period_id.id, writeoff_journal_id=st.journal_id.id, context=context)
297                     else:
298                         account_move_line_obj.reconcile_partial(cr, uid, torec, 'statement', context)
299                     #except:
300                     #    raise osv.except_osv(_('Error !'), _('Unable to reconcile entry "%s": %.2f') % (move.name, move.amount))
301
302                 if st.journal_id.entry_posted:
303                     account_move_obj.write(cr, uid, [move_id], {'state':'posted'})
304             done.append(st.id)
305         self.write(cr, uid, done, {'state':'confirm'}, context=context)
306         return True
307
308     def button_cancel(self, cr, uid, ids, context={}):
309         done = []
310         for st in self.browse(cr, uid, ids, context):
311             if st.state=='draft':
312                 continue
313             ids = []
314             for line in st.line_ids:
315                 ids += [x.id for x in line.move_ids]
316             self.pool.get('account.move').unlink(cr, uid, ids, context)
317             done.append(st.id)
318         self.write(cr, uid, done, {'state':'draft'}, context=context)
319         return True
320
321     def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None):
322         if not journal_id:
323             return {'value': {'currency': False}}
324
325         account_journal_obj = self.pool.get('account.journal')
326         res_users_obj = self.pool.get('res.users')
327         res_currency_obj = self.pool.get('res.currency')
328
329         cursor.execute('SELECT balance_end_real \
330                 FROM account_bank_statement \
331                 WHERE journal_id = %s \
332                 ORDER BY date DESC,id DESC LIMIT 1', (journal_id,))
333         res = cursor.fetchone()
334         balance_start = res and res[0] or 0.0
335
336         currency_id = account_journal_obj.browse(cursor, user, journal_id,
337                 context=context).currency.id
338         if not currency_id:
339             currency_id = res_users_obj.browse(cursor, user, user,
340                     context=context).company_id.currency_id.id
341         currency = res_currency_obj.name_get(cursor, user, [currency_id],
342                 context=context)[0]
343         return {'value': {'balance_start': balance_start, 'currency': currency}}
344
345     def unlink(self, cr, uid, ids, context=None):
346         stat = self.read(cr, uid, ids, ['state'])
347         unlink_ids = []
348         for t in stat:
349             if t['state'] in ('draft'):
350                 unlink_ids.append(t['id'])
351             else:
352                 raise osv.except_osv(_('Invalid action !'), _('Cannot delete bank statement which are already confirmed !'))
353         osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
354         return True
355     
356 account_bank_statement()
357
358
359 class account_bank_statement_reconcile(osv.osv):
360     _name = "account.bank.statement.reconcile"
361     _description = "Statement reconcile"
362
363     def _total_entry(self, cursor, user, ids, name, attr, context=None):
364         result = {}
365         for o in self.browse(cursor, user, ids, context=context):
366             result[o.id] = 0.0
367             for line in o.line_ids:
368                 result[o.id] += line.debit - line.credit
369         return result
370
371     def _total_new(self, cursor, user, ids, name, attr, context=None):
372         result = {}
373         for o in self.browse(cursor, user, ids, context=context):
374             result[o.id] = 0.0
375             for line in o.line_new_ids:
376                 result[o.id] += line.amount
377         return result
378
379     def _total_balance(self, cursor, user, ids, name, attr, context=None):
380         result = {}
381         for o in self.browse(cursor, user, ids, context=context):
382             result[o.id] = o.total_new - o.total_entry + o.total_amount
383         return result
384
385     def _total_amount(self, cursor, user, ids, name, attr, context=None):
386         res = {}
387         res_currency_obj = self.pool.get('res.currency')
388         res_users_obj = self.pool.get('res.users')
389
390         company_currency_id = res_users_obj.browse(cursor, user, user,
391                 context=context).company_id.currency_id.id
392         currency_id = context.get('currency_id', company_currency_id)
393
394         acc_cur = None
395         if context.get('journal_id', False) and context.get('account_id',False):
396             st =self.pool.get('account.journal').browse(cursor, user, context['journal_id'])
397             acc = self.pool.get('account.account').browse(cursor, user, context['account_id'])
398             acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc
399
400         for reconcile_id in ids:
401             res[reconcile_id] = res_currency_obj.compute(cursor, user,
402                     currency_id, company_currency_id,
403                     context.get('amount', 0.0), context=context, account=acc_cur)
404         return res
405
406     def _default_amount(self, cursor, user, context=None):
407         if context is None:
408             context = {}
409         res_currency_obj = self.pool.get('res.currency')
410         res_users_obj = self.pool.get('res.users')
411
412         company_currency_id = res_users_obj.browse(cursor, user, user,
413                 context=context).company_id.currency_id.id
414         currency_id = context.get('currency_id', company_currency_id)
415
416         acc_cur = None
417         if context.get('journal_id', False) and context.get('account_id',False):
418             st =self.pool.get('account.journal').browse(cursor, user, context['journal_id'])
419             acc = self.pool.get('account.account').browse(cursor, user, context['account_id'])
420             acc_cur = (( context.get('amount',0.0)<=0) and st.default_debit_account_id) or acc
421
422         return res_currency_obj.compute(cursor, user,
423                 currency_id, company_currency_id,
424                 context.get('amount', 0.0), context=context, account=acc_cur)
425
426     def _total_currency(self, cursor, user, ids, name, attrs, context=None):
427         res = {}
428         res_users_obj = self.pool.get('res.users')
429
430         company_currency_id = res_users_obj.browse(cursor, user, user,
431                 context=context).company_id.currency_id.id
432
433         for reconcile_id in ids:
434             res[reconcile_id] = company_currency_id
435         return res
436
437     def _default_currency(self, cursor, user, context=None):
438         res_users_obj = self.pool.get('res.users')
439
440         return res_users_obj.browse(cursor, user, user,
441                 context=context).company_id.currency_id.id
442
443
444     def _total_second_amount(self, cursor, user, ids, name, attr,
445             context=None):
446         res = {}
447         for reconcile_id in ids:
448             res[reconcile_id] = context.get('amount', 0.0)
449         return res
450
451     def _total_second_currency(self, cursor, user, ids, name, attr, context=None):
452         res = {}
453         for reconcile_id in ids:
454             res[reconcile_id] = context.get('currency_id', False)
455         return res
456
457     def name_get(self, cursor, user, ids, context=None):
458         res= []
459         for o in self.browse(cursor, user, ids, context=context):
460             result = 0.0
461             res_currency = ''
462             for line in o.line_ids:
463                 if line.amount_currency and line.currency_id:
464                     result += line.amount_currency
465                     res_currency = line.currency_id.code
466                 else:
467                     result += line.debit - line.credit
468             if res_currency:
469                 res_currency = ' ' + res_currency
470             res.append((o.id, '[%.2f'% (result - o.total_new,) + res_currency + ']' ))
471         return res
472
473     _columns = {
474         'name': fields.char('Date', size=64, required=True),
475         'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
476         'line_new_ids': fields.one2many('account.bank.statement.reconcile.line',
477             'line_id', 'Write-Off'),
478         'total_entry': fields.function(_total_entry, method=True,
479             string='Total entries'),
480         'total_new': fields.function(_total_new, method=True,
481             string='Total write-off'),
482         'total_second_amount': fields.function(_total_second_amount,
483             method=True, string='Payment amount',
484             help='The amount in the currency of the journal'),
485         'total_second_currency': fields.function(_total_second_currency, method=True,
486             string='Currency', type='many2one', relation='res.currency',
487             help='The currency of the journal'),
488         'total_amount': fields.function(_total_amount, method=True,
489             string='Payment amount'),
490         'total_currency': fields.function(_total_currency, method=True,
491             string='Currency', type='many2one', relation='res.currency'),
492         'total_balance': fields.function(_total_balance, method=True,
493             string='Balance'),
494         #line_ids define in account.py
495         'statement_line': fields.one2many('account.bank.statement.line',
496              'reconcile_id', 'Bank Statement Line'),
497     }
498     _defaults = {
499         'name': lambda *a: time.strftime('%Y-%m-%d'),
500         'partner_id': lambda obj, cursor, user, context=None: \
501                 context.get('partner', False),
502         'total_amount': _default_amount,
503         'total_currency': _default_currency,
504         'total_second_amount':  lambda obj, cursor, user, context=None: \
505                 context.get('amount', 0.0),
506         'total_second_currency': lambda obj, cursor, user, context=None: \
507                 context.get('currency_id', False),
508         'total_balance': _default_amount,
509     }
510 account_bank_statement_reconcile()
511
512 class account_bank_statement_reconcile_line(osv.osv):
513     _name = "account.bank.statement.reconcile.line"
514     _description = "Statement reconcile line"
515     _columns = {
516         'name': fields.char('Description', size=64, required=True),
517         'account_id': fields.many2one('account.account', 'Account', required=True),
518         'line_id': fields.many2one('account.bank.statement.reconcile', 'Reconcile'),
519         'amount': fields.float('Amount', required=True),
520         'analytic_id': fields.many2one('account.analytic.account',"Analytic Account")
521     }
522     _defaults = {
523         'name': lambda *a: 'Write-Off',
524     }
525 account_bank_statement_reconcile_line()
526
527
528 class account_bank_statement_line(osv.osv):
529
530     def onchange_partner_id(self, cursor, user, line_id, partner_id, type, currency_id,
531             context={}):
532         if not partner_id:
533             return {}
534         res_currency_obj = self.pool.get('res.currency')
535         res_users_obj = self.pool.get('res.users')
536
537         company_currency_id = res_users_obj.browse(cursor, user, user,
538                 context=context).company_id.currency_id.id
539
540         if not currency_id:
541             currency_id = company_currency_id
542
543         part = self.pool.get('res.partner').browse(cursor, user, partner_id,
544                 context=context)
545         if type == 'supplier':
546             account_id = part.property_account_payable.id
547         else:
548             account_id =  part.property_account_receivable.id
549
550         cursor.execute('SELECT sum(debit-credit) \
551                 FROM account_move_line \
552                 WHERE (reconcile_id is null) \
553                     AND partner_id = %s \
554                     AND account_id=%s', (partner_id, account_id))
555         res = cursor.fetchone()
556         balance = res and res[0] or 0.0
557
558         balance = res_currency_obj.compute(cursor, user, company_currency_id,
559                 currency_id, balance, context=context)
560         return {'value': {'amount': balance, 'account_id': account_id}}
561
562     def _reconcile_amount(self, cursor, user, ids, name, args, context=None):
563         if not ids:
564             return {}
565         res_currency_obj = self.pool.get('res.currency')
566         res_users_obj = self.pool.get('res.users')
567
568         res = {}
569         company_currency_id = res_users_obj.browse(cursor, user, user,
570                 context=context).company_id.currency_id.id
571
572         for line in self.browse(cursor, user, ids, context=context):
573             if line.reconcile_id:
574                 res[line.id] = res_currency_obj.compute(cursor, user,
575                         company_currency_id, line.statement_id.currency.id,
576                         line.reconcile_id.total_entry, context=context)
577             else:
578                 res[line.id] = 0.0
579         return res
580
581     _order = "date,name desc"
582     _name = "account.bank.statement.line"
583     _description = "Bank Statement Line"
584     _columns = {
585         'name': fields.char('Name', size=64, required=True),
586         'date': fields.date('Date', required=True),
587         'amount': fields.float('Amount'),
588         'type': fields.selection([
589             ('supplier','Supplier'),
590             ('customer','Customer'),
591             ('general','General')
592             ], 'Type', required=True),
593         'partner_id': fields.many2one('res.partner', 'Partner'),
594         'account_id': fields.many2one('account.account','Account',
595             required=True),
596         'statement_id': fields.many2one('account.bank.statement', 'Statement',
597             select=True, required=True, ondelete='cascade'),
598         'reconcile_id': fields.many2one('account.bank.statement.reconcile',
599             'Reconcile', states={'confirm':[('readonly',True)]}),
600         'move_ids': fields.many2many('account.move',
601             'account_bank_statement_line_move_rel', 'move_id','statement_id',
602             'Moves'),
603         'ref': fields.char('Reference', size=32),
604         'note': fields.text('Notes'),
605         'reconcile_amount': fields.function(_reconcile_amount,
606             string='Amount reconciled', method=True, type='float'),
607         'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of bank statement line."),
608     }
609     _defaults = {
610         'name': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement.line'),
611         'date': lambda *a: time.strftime('%Y-%m-%d'),
612         'type': lambda *a: 'general',
613         'sequence': lambda *a: 10,
614     }
615
616 account_bank_statement_line()
617
618
619
620 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
621