-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdecimal_pre_currency.py
102 lines (89 loc) · 3.89 KB
/
decimal_pre_currency.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*- encoding: utf-8 -*-
###########################################################################
# Module Writen to OpenERP, Open Source Management Solution
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
# All Rights Reserved
# Credits######################################################
# Coded by: Maria Gabriela Quilarque <[email protected]>
# Planified by: Nhomar Hernandez <[email protected]>
# Audited by: Maria Gabriela Quilarque <[email protected]>
# Modified by: Daniel Blanco <[email protected]>
#
#############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##############################################################################
from openerp.osv import fields, osv
import time
from openerp.addons.decimal_precision import decimal_precision as dp
class res_currency_rate(osv.Model):
_inherit = "res.currency.rate"
_columns = {
'rate': fields.float('Rate',
digits_compute=dp.get_precision('Currency'), required=True,
help='The rate of the currency to the currency of rate 1'),
}
# class res_currency(osv.Model):
#
# def _current_rate(self, cr, uid, ids, name, arg, context=None):
# if context is None:
# context = {}
# res = {}
# if 'date' in context:
# date = context['date']
# else:
# date = time.strftime('%Y-%m-%d')
# date = date or time.strftime('%Y-%m-%d')
# for id in ids:
# cr.execute(
# "SELECT currency_id, rate\
# FROM res_currency_rate\
# WHERE currency_id = %s\
# AND name <= %s\
# ORDER BY name desc LIMIT 1", (id, date))
# if cr.rowcount:
# id, rate = cr.fetchall()[0]
# res[id] = rate
# else:
# res[id] = 0
# return res
#
# _inherit = "res.currency"
# _columns = {
# 'rate': fields.function(_current_rate, method=True,
# string='Current Rate', digits_compute=dp.get_precision('Currency'),
# help='The rate of the currency to the currency of rate 1'),
# 'rounding': fields.float('Rounding factor',
# digits_compute=dp.get_precision('Currency')),
#
# }
class res_currency(osv.Model):
_name = "res.currency"
_inherit = "res.currency"
def _current_rate(self, cr, uid, ids, name, arg, context=None):
return super(
res_currency,self)._current_rate(cr, uid, ids, name, arg, context)
def _current_rate_silent(self, cr, uid, ids, name, arg, context=None):
return super(
res_currency,self)._current_rate_silent(
cr, uid, ids, name, arg, context)
_columns = {
'rate': fields.function(
_current_rate, string='Current Rate',
digits_compute=dp.get_precision('Currency'),
help='The rate of the currency to the currency of rate 1.'),
'rate_silent': fields.function(_current_rate_silent, string='Current Rate',
digits_compute=dp.get_precision('Currency'),
help="""The rate of the currency to the currency of rate 1
(0 if no rate defined).""")
}