Launchpad automatic translations update.
[odoo/odoo.git] / addons / account_coda / account_coda.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 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
24 from osv import osv,fields
25 from tools.translate import _
26
27 class account_coda(osv.osv):
28     _name = "account.coda"
29     _description = "coda for an Account"
30     _columns = {
31         'name': fields.binary('Coda file', readonly=True, help="Store the detail of bank statements"),
32         'statement_ids': fields.one2many('account.bank.statement', 'coda_id', 'Generated Bank Statements', readonly=True),
33         'note': fields.text('Import log', readonly=True),
34         'journal_id': fields.many2one('account.journal', 'Journal', readonly=True, select=True, help="Bank Journal"),
35         'date': fields.date('Date', readonly=True, select=True, help="Import Date"),
36         'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
37         'company_id': fields.many2one('res.company', 'Company', readonly=True)
38     }
39     _defaults = {
40         'date': lambda *a: time.strftime('%Y-%m-%d'),
41         'user_id': lambda self,cr,uid,context: uid,
42         'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'account.coda', context=c),
43     }
44
45     def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
46         if context is None: 
47             context = {}
48         res = super(account_coda, self).search(cr, user, args=args, offset=offset, limit=limit, order=order,
49                 context=context, count=count)
50         if context.get('bank_statement', False) and not res:
51             raise osv.except_osv('Error', _('Coda file not found for bank statement !!'))
52         return res
53
54 account_coda()
55
56 class account_bank_statement(osv.osv):
57     _inherit = "account.bank.statement"
58     _columns = {
59         'coda_id':fields.many2one('account.coda', 'Coda'),
60     }
61
62 account_bank_statement()
63
64 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: