1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# -*- encoding: utf-8 -*-
# __author__ = jeff@openerp.cn
# __thanks__ = [oldrev@gmail.com, popkar77@gmail.com]
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import rml_parse
from report import report_sxw
from tools.translate import _
class AccountMoveParser(rml_parse.rml_parse):
'''
Parser for account move report
'''
def __init__(self, cr, uid, name, context):
super(AccountMoveReportParser, self).__init__(cr, uid, name, context)
self.localcontext.update({
'time': time,
'rate': self._get_exchange_rate,
'price':self._get_unit_price,
})
def _get_exchange_rate(self, line):
'''
Exchange rate: Debit or Credit / currency ammount
Why not get it from currency code + date ?
'''
exchange_rate = False
if line.amount_currency:
if line.debit > 0:
exchange_rate = line.debit/line.amount_currency
if line.credit > 0:
exchange_rate = line.credit/line.amount_currency
return exchange_rate
def _get_unit_price(self, line):
'''
Unit priceļ¼Debit or Credit / Quantity
'''
unit_price = False
if line.quantity:
if line.debit > 0:
unit_price = line.debit/line.quantity
if line.credit > 0:
unit_price = line.credit/line.quantity
return unit_price
#Register report parser
report_sxw.report_sxw('report.account.move', 'account.move', \
'addons/oecn_account_print/report/account_move.sxw', \
parser=AccountMoveParser)
|