~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to report_profit/account.py

  • Committer: nhomar at vauxoo
  • Date: 2011-06-11 22:55:27 UTC
  • Revision ID: nhomar@vauxoo.com-20110611225527-v2mlv4fbx38j0gg3
[SHELDON ] commiting ortografy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- encoding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
# Copyright (c) 2010 Latinux Inc (http://www.latinux.com/) All Rights Reserved.
5
 
#                    Javier Duran <jduran@corvus.com.ve>
6
 
#
7
 
#
8
 
# WARNING: This program as such is intended to be used by professional
9
 
# programmers who take the whole responsability of assessing all potential
10
 
# consequences resulting from its eventual inadequacies and bugs
11
 
# End users who are looking for a ready-to-use solution with commercial
12
 
# garantees and support are strongly adviced to contract a Free Software
13
 
# Service Company
14
 
#
15
 
# This program is Free Software; you can redistribute it and/or
16
 
# modify it under the terms of the GNU General Public License
17
 
# as published by the Free Software Foundation; either version 2
18
 
# of the License, or (at your option) any later version.
19
 
#
20
 
# This program is distributed in the hope that it will be useful,
21
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 
# GNU General Public License for more details.
24
 
#
25
 
# You should have received a copy of the GNU General Public License
26
 
# along with this program; if not, write to the Free Software
27
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28
 
#
29
 
##############################################################################
30
 
 
31
 
from openerp.osv import osv, fields
32
 
 
33
 
 
34
 
class account_move_line(osv.Model):
35
 
    _inherit = 'account.move.line'
36
 
    _description = "Entry lines"
37
 
 
38
 
    def find(self, cr, uid, **kwargs):
39
 
        res = []
40
 
        cond_str = ''
41
 
        cond_val = []
42
 
 
43
 
        if kwargs.get('dt', False):
44
 
            if cond_str:
45
 
                cond_str += ' AND '
46
 
            cond_str += 'aml.date=%s'
47
 
            cond_val.append(kwargs['dt'])
48
 
        if kwargs.get('acc_id', False):
49
 
            if cond_str:
50
 
                cond_str += ' AND '
51
 
            cond_str += 'aml.account_id=%s'
52
 
            cond_val.append(kwargs['acc_id'])
53
 
        if kwargs.get('prd_id', False):
54
 
            if cond_str:
55
 
                cond_str += ' AND '
56
 
            cond_str += 'aml.product_id=%s'
57
 
            cond_val.append(kwargs['prd_id'])
58
 
        if kwargs.get('mov_id', False):
59
 
            if cond_str:
60
 
                cond_str += ' AND '
61
 
            cond_str += 'aml.move_id=%s'
62
 
            cond_val.append(kwargs['mov_id'])
63
 
        if kwargs.get('per_id', False):
64
 
            if cond_str:
65
 
                cond_str += ' AND '
66
 
            cond_str += 'aml.period_id=%s'
67
 
            cond_val.append(kwargs['per_id'])
68
 
        if kwargs.get('jou_id', False):
69
 
            if cond_str:
70
 
                cond_str += ' AND '
71
 
            cond_str += 'aml.journal_id=%s'
72
 
            cond_val.append(kwargs['jou_id'])
73
 
        if kwargs.get('par_id', False):
74
 
            if cond_str:
75
 
                cond_str += ' AND '
76
 
            cond_str += 'aml.partner_id=%s'
77
 
            cond_val.append(kwargs['par_id'])
78
 
        if kwargs.get('cur_id', False):
79
 
            if cond_str:
80
 
                cond_str += ' AND '
81
 
            cond_str += 'aml.currency_id=%s'
82
 
            cond_val.append(kwargs['cur_id'])
83
 
        if kwargs.get('qty', False):
84
 
            if cond_str:
85
 
                cond_str += ' AND '
86
 
            cond_str += 'aml.quantity=%s'
87
 
            cond_val.append(kwargs['qty'])
88
 
        if kwargs.get('name', False):
89
 
            if cond_str:
90
 
                cond_str += ' AND '
91
 
            cond_str += 'aml.name=%s'
92
 
            cond_val.append(kwargs['name'])
93
 
        if kwargs.get('ref', False):
94
 
            if cond_str:
95
 
                cond_str += ' AND '
96
 
            cond_str += 'aml.ref=%s'
97
 
            cond_val.append(kwargs['ref'])
98
 
        if kwargs.get('debit', False):
99
 
            if cond_str:
100
 
                cond_str += ' AND '
101
 
            cond_str += 'aml.debit=%s'
102
 
            cond_val.append(kwargs['debit'])
103
 
        if kwargs.get('credit', False):
104
 
            if cond_str:
105
 
                cond_str += ' AND '
106
 
            cond_str += 'aml.credit=%s'
107
 
            cond_val.append(kwargs['credit'])
108
 
 
109
 
        if cond_str:
110
 
            cond_str = ' WHERE ' + cond_str
111
 
 
112
 
#        print 'xxxxcondicion: ',cond_str
113
 
 
114
 
        sql = 'SELECT aml.id FROM account_move_line aml' + \
115
 
            cond_str % tuple(cond_val)
116
 
#        print 'xxxxsql: ',sql
117
 
        cr.execute(sql)
118
 
        res = map(lambda x: x[0], cr.fetchall())
119
 
 
120
 
        if not res:
121
 
            return False
122
 
        return res
123