1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2012 Agile Business Group sagl (<http://www.agilebg.com>)
5
# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as published
10
# by 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 Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from osv import fields, osv
25
class account_move_line(osv.osv):
27
_inherit = 'account.move.line'
30
'currency_rate_used': fields.float('Rate Used', digits=(12,6), readonly=True),
33
def create(self, cr, uid, vals, context=None, check=True):
36
if vals.get('amount_currency', False) and not context.get('currency_rate_used', False):
37
print "account_move_line_currency_rate - Warning: writing 'amount_currency' but context does not contain 'currency_rate_used'"
38
elif vals.get('amount_currency', False) and context.get('currency_rate_used', False):
39
vals.update({'currency_rate_used': context['currency_rate_used']})
40
res = super(account_move_line, self).create(cr, uid, vals, context=context, check=check)
41
#context['currency_rate_used'] = False
44
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
47
if vals.get('amount_currency', False) and not context.get('currency_rate_used', False):
48
print "account_move_line_currency_rate - Warning: writing 'amount_currency' but context does not contain 'currency_rate_used'"
49
elif vals.get('amount_currency', False) and context.get('currency_rate_used', False):
50
vals.update({'currency_rate_used': context['currency_rate_used']})
51
res = super(account_move_line, self).write(
52
cr, uid, ids, vals, context=context, check=check, update_check=update_check)
53
#context['currency_rate_used'] = False