~xmo-deactivatedaccount/openobject-addons/5.0-sql-fixes

« back to all changes in this revision

Viewing changes to account/project/project.py

  • Committer: Xavier Morel
  • Date: 2010-03-05 10:53:36 UTC
  • Revision ID: xmo@tinyerp.com-20100305105336-w41gtvxqorjav6r3
[fix] account: move logging back to netsvc.Logger.notifyChannel form `logging`

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
#
21
21
##############################################################################
22
 
import logging
23
22
import time
24
23
import operator
25
24
 
 
25
import netsvc
26
26
from osv import fields
27
27
from osv import osv
28
28
 
33
33
class account_analytic_account(osv.osv):
34
34
    _name = 'account.analytic.account'
35
35
    _description = 'Analytic Accounts'
36
 
    __logger = logging.getLogger('addons.' + _name)
 
36
    logger = netsvc.Logger()
37
37
 
38
38
    def _credit_calc(self, cr, uid, ids, name, arg, context={}):
39
 
        self.__logger.debug('Entering _credit_calc; ids:%s', ids)
 
39
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
40
                                  'Entering _credit_calc; ids:%s'%ids)
40
41
        if not ids: return {}
41
42
 
42
43
        where_date = ''
52
53
                   "GROUP BY a.id" % (where_date),
53
54
                   dict(context, ids=tuple(ids)))
54
55
        r = dict(cr.fetchall())
55
 
        self.__logger.debug('_credit_calc results: %s', r)
 
56
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
57
                                  '_credit_calc results: %s'%r)
56
58
        for i in ids:
57
59
            r.setdefault(i,0.0)
58
60
        return r
59
61
 
60
62
    def _debit_calc(self, cr, uid, ids, name, arg, context={}):
61
 
        self.__logger.debug('Entering _debit_calc; ids:%s', ids)
 
63
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
64
                                  'Entering _debit_calc; ids:%s'%ids)
62
65
        if not ids: return {}
63
66
 
64
67
        where_date = ''
74
77
                   "GROUP BY a.id" % (where_date),
75
78
                   dict(context, ids=tuple(ids)))
76
79
        r = dict(cr.fetchall())
77
 
        self.__logger.debug('_debit_calc results: %s', r)
 
80
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
81
                                  '_debut_calc results: %s'%r)
78
82
        for i in ids:
79
83
            r.setdefault(i,0.0)
80
84
        return r
82
86
    def _balance_calc(self, cr, uid, ids, name, arg, context={}):
83
87
        res = {}
84
88
        ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
85
 
        self.__logger.debug('Entering _balance_calc; ids:%s; ids2:%s',
86
 
                          ids, ids2)
 
89
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
90
                                  'Entering _balance_calc; ids:%s; ids2:%s'%(
 
91
                            ids, ids2))
87
92
 
88
93
        for i in ids:
89
94
            res.setdefault(i,0.0)
106
111
 
107
112
        for account_id, sum in cr.fetchall():
108
113
            res[account_id] = sum
109
 
        logging.debug('_balance_calc, (id, sum): %s', res)
 
114
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
115
                                  '_balance_calc, (id, sum): %s'%res)
110
116
 
111
117
        cr.execute("SELECT a.id, r.currency_id "
112
118
                   "FROM account_analytic_account a "
114
120
                   "WHERE a.id in %s", (tuple(ids),))
115
121
 
116
122
        currency = dict(cr.fetchall())
117
 
        self.__logger.debug('_balance_calc currency: %s', currency)
 
123
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
124
                                  '_balance_calc currency: %s'%currency)
118
125
 
119
126
        res_currency= self.pool.get('res.currency')
120
127
        for id in ids:
137
144
        return dict([(i, res[i]) for i in ids ])
138
145
 
139
146
    def _quantity_calc(self, cr, uid, ids, name, arg, context={}):
140
 
        self.__logger.debug('_quantity_calc ids:%s', ids)
 
147
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
148
                                  '_quantity_calc ids:%s'%ids)
141
149
        #XXX must convert into one uom
142
150
        res = {}
143
151
        ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
162
170
 
163
171
        for account_id, sum in cr.fetchall():
164
172
            res[account_id] = sum
165
 
        self.__logger.debug('_quantity_calc, (id, sum): %s', res)
 
173
        self.logger.notifyChannel('addons.'+self._name, netsvc.LOG_DEBUG,
 
174
                                  '_quantity_calc, (id, sum): %s'%res)
166
175
 
167
176
        for id in ids:
168
177
            if id not in ids2: