1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2004-2010 Pexego Sistemas Informáticos. All Rights Reserved
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
##############################################################################
21
Extensions to the cash statements to add analytical accounting features.
25
"Borja López Soilán (Pexego) <borjals@pexego.es>"
28
from osv import osv, fields
31
class cash_statement_line_type(osv.osv):
33
Extend the Cash Statement Line Type to add the analytic account.
35
_inherit = 'account.bank.statement.line.type'
38
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
41
cash_statement_line_type()
45
class cash_statement_line(osv.osv):
47
Extend the cash statement lines to add the analytic-related behaviour.
49
_inherit = 'account.bank.statement.line'
52
def cash_line_on_change_line_type_id(self, cr, uid, line_id, partner_id, original_type, line_type_id, context=None):
54
Update the analytic account when the line type changes.
56
res = super(cash_statement_line, self).cash_line_on_change_line_type_id(cr, uid, line_id, partner_id, original_type, line_type_id, context=context)
59
line_type = self.pool.get('account.bank.statement.line.type').browse(cr, uid, line_type_id)
62
# Set the analytic account
64
if line_type.analytic_account_id:
65
res['value']['analytic_account_id'] = line_type.analytic_account_id.id