1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2014 SF Soluciones.
5
# (http://www.sfsoluciones.com)
6
# contacto@sfsoluciones.com
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from osv import osv, fields
25
import openerp.addons.decimal_precision as dp
27
class user_transaction_history(osv.osv):
28
_name = 'user.transaction.history'
29
_description = 'Model to keep record of user payments and refund'
30
_rec_name = 'transaction_date'
32
def _get_history(self, cr, uid, ids, context=None):
33
move_line_pool = self.pool.get('account.move.line')
34
history_pool = self.pool.get('user.transaction.history')
35
history_ids = history_pool.search(cr, uid, [('move_line_id', 'in', ids)], context=context)
38
def _get_voucher_history(self, cr, uid, ids, context=None):
39
voucher_pool = self.pool.get('account.voucher')
40
history_pool = self.pool.get('user.transaction.history')
41
history_ids = history_pool.search(cr, uid, [('payment_id', 'in', ids)], context=context)
44
def _get_transaction_date(self, cr, uid, ids, name, args, context=None):
46
for history_obj in self.browse(cr, uid, ids, context=context):
47
if history_obj.payment_id:
48
res[history_obj.id] = history_obj.payment_id.date
50
res[history_obj.id] = history_obj.move_line_id.date
54
'user_id': fields.many2one('res.users', 'User'),
55
'transaction_date': fields.function(_get_transaction_date, type="date", string="Transaction Date",
57
'account.move.line': (_get_history, ['date'], 10),
58
'account.voucher': (_get_voucher_history, ['date'], 10),
59
'user.transaction.history' : (lambda self, cr, uid, ids, c={}: ids, [], 5),
61
'transaction_type': fields.selection([('payment', 'Payment'), ('refund', 'Refund')],
63
'invoice_id': fields.many2one('account.invoice', 'Related Invoice'),
64
'payment_id': fields.many2one('account.voucher', 'Related Payment'),
65
'move_line_id': fields.many2one('account.move.line', 'Related Journal Item'),
66
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account'))
68
user_transaction_history()
71
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: