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
28
class account_move_line(osv.osv):
29
_inherit = 'account.move.line'
31
def join_without_redundancy(self, text='', string=''):
33
Add string @ begining of text like that:
34
mystring1 - mysupertext
36
If mystring1 already exist, increment 1:
37
mystring1 - mysupertext
39
mystring2 - mysupertext
42
result = ''.join([string, '1 - ', text])
43
if text == '' or string == '':
45
pattern = re.compile('\%s([0-9]*) - ' % string)
46
m = re.match(pattern, text)
48
number = m.groups() and m.groups()[0]
49
replacement = string + str(int(number) + 1) + ' - '
50
result = re.sub(pattern, replacement, text, 1)
54
'source_date': fields.date('Source date', help="Date used for FX rate re-evaluation"),
55
'move_state': fields.related('move_id', 'state', string="Move state", type="selection", selection=[('draft', 'Draft'), ('posted', 'Posted')],
56
help="This indicates the state of the Journal Entry."),
60
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: