2
#-*- encoding:utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2011 TeMPO Consulting, MSF. All Rights Reserved
7
# Developer: Olivier DOSSMANN
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
25
from osv import fields
26
import decimal_precision as dp
28
class account_analytic_line(osv.osv):
29
_inherit = 'account.analytic.line'
31
def __init__(self, pool, cr):
33
Permits to OpenERP not attempt to update DB field with the old field_function
35
super(account_analytic_line, self).__init__(pool, cr)
36
if self.pool._store_function.get(self._name, []):
38
for fct in self.pool._store_function[self._name]:
39
if fct[1] not in ['currency_id', 'amount_currency']:
41
self.pool._store_function[self._name] = newstore
43
def join_without_redundancy(self, text='', string=''):
44
return self.pool.get('account.move.line').join_without_redundancy(text, string)
47
'reversal_origin': fields.many2one('account.analytic.line', string="Reversal origin", readonly=True, help="Line that have been reversed."),
48
'invoice_line_id': fields.many2one('account.invoice.line', string="Invoice line", readonly=True, help="Invoice line from which this line is linked.", ondelete='cascade'),
49
'source_date': fields.date('Source date', help="Date used for FX rate re-evaluation"),
50
'amount_currency': fields.float(string="Amount currency", digits_compute=dp.get_precision('Account'), readonly="True", required=True, help="The amount expressed in an optional other currency."),
51
'currency_id': fields.many2one('res.currency', string="Currency", required=True),
54
def reverse(self, cr, uid, ids, context={}):
56
Reverse an analytic line
60
if isinstance(ids, (int, long)):
63
for al in self.browse(cr, uid, ids, context=context):
65
'name': self.join_without_redundancy(al.name, 'REV'),
66
'amount': al.amount * -1,
67
'date': al.source_date or al.date,
68
'reversal_origin': al.id,
69
'amount_currency': al.amount_currency * -1,
70
'currency_id': al.currency_id.id,
72
new_al = self.copy(cr, uid, al.id, vals, context=context)
76
account_analytic_line()
77
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: