~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to pxgo_bank_statement_analytic/bank_statement.py

  • Committer: Borja L.S.
  • Date: 2010-06-18 08:46:36 UTC
  • Revision ID: borjals@pexego.es-20100618084636-6534hnl1h2gool92
[ADD] pxgo_bank_statement_analytic: New module to create analytic entries from bank statements.

Extends the Bank Statements to add support for analytic accounting.

A analytic account field will be added to bank statement lines, allowing
the user to directly register small expenses or incomes on analytic accounts.

This may be useful for petty cash management.

Thanks to Igalia (http://www.igalia.com/) for sponsoring this module :) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Copyright (C) 2004-2010 Pexego Sistemas Informáticos. All Rights Reserved
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.
 
18
#
 
19
##############################################################################
 
20
"""
 
21
Extensions to the bank statements to add analytical accounting features.
 
22
"""
 
23
 
 
24
__authors__ = [
 
25
    "Borja López Soilán (Pexego) <borjals@pexego.es>"
 
26
]
 
27
 
 
28
from osv import osv, fields
 
29
 
 
30
 
 
31
class bank_statement(osv.osv):
 
32
    """
 
33
    Extend the bank statement to add the analytic account when creating
 
34
    the accounting moves.
 
35
    """
 
36
    _inherit = 'account.bank.statement'
 
37
 
 
38
    def button_confirm(self, cr, uid, ids, context={}):
 
39
        """
 
40
        Extend the button confirm action, to add the analytic account references
 
41
        to the account move lines being created.
 
42
        """
 
43
        super(bank_statement, self).button_confirm(cr, uid, ids, context=context)
 
44
        aml_facade = self.pool.get('account.move.line')
 
45
        for st in self.browse(cr, uid, ids, context):
 
46
            for st_line in st.line_ids:
 
47
                if st_line.analytic_account_id:
 
48
                    for move in st_line.move_ids:
 
49
                        for line in move.line_id:
 
50
                            if line.account_id == st_line.account_id:
 
51
                                aml_facade.write(cr, uid, [line.id], {
 
52
                                        'analytic_account_id': st_line.analytic_account_id.id
 
53
                                    })
 
54
 
 
55
bank_statement()
 
56
 
 
57
 
 
58
 
 
59
class bank_statement_line(osv.osv):
 
60
    """
 
61
    Extend the bank statement to add the analytic account reference.
 
62
    """
 
63
    _inherit = 'account.bank.statement.line'
 
64
 
 
65
    _columns = {
 
66
        'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
 
67
    }
 
68
 
 
69
bank_statement_line()
 
70