[MERGE] forward port of branch 7.0 up to 529e920
[odoo/odoo.git] / addons / account / project / project.py
1 # -*- coding: 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 from openerp.osv import fields, osv
23
24 class account_analytic_journal(osv.osv):
25     _name = 'account.analytic.journal'
26     _description = 'Analytic Journal'
27     _columns = {
28         'name': fields.char('Journal Name', size=64, required=True),
29         'code': fields.char('Journal Code', size=8),
30         'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the analytic journal without removing it."),
31         'type': fields.selection([('sale','Sale'), ('purchase','Purchase'), ('cash','Cash'), ('general','General'), ('situation','Situation')], 'Type', size=32, required=True, help="Gives the type of the analytic journal. When it needs for a document (eg: an invoice) to create analytic entries, OpenERP will look for a matching journal of the same type."),
32         'line_ids': fields.one2many('account.analytic.line', 'journal_id', 'Lines'),
33         'company_id': fields.many2one('res.company', 'Company', required=True),
34     }
35     _defaults = {
36         'active': True,
37         'type': 'general',
38         'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
39     }
40
41     def copy_data(self, cr, uid, id, default=None, context=None):
42         if not default:
43             default = {}
44         default.update({'line_ids': False})
45         return super(account_analytic_journal, self).copy_data(cr, uid, id, default, context)
46
47
48 class account_journal(osv.osv):
49     _inherit="account.journal"
50
51     _columns = {
52         'analytic_journal_id':fields.many2one('account.analytic.journal','Analytic Journal', help="Journal for analytic entries"),
53     }
54
55
56 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: