# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#    Copyright (C) 2010-2010 Camptocamp Austria (<http://www.camptocamp.at>)
#    Copyright (C) 2011-2011 Swing Entwicklung betrieblicher Informationssysteme GmbH (<http://www.swing-system.com>)
#
#    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 osv import fields, osv

class ir_sequence_installer(osv.osv_memory):
    _name    = 'ir.sequence.installer'
    _inherit = 'res.config.installer'

    def execute(self, cr, uid, ids, context=None):

        where = ''
        count = self.pool.get('ir.module.module').search_count(cr, uid, ['&', ('name', '=', 'account_sequence_fiscalyear'), ('state', 'in', ['installed'])])

        if count > 0:
            where = """
                 WHERE id IN (SELECT sequence_main_id 
                               FROM account_sequence_fiscalyear) """

        cr.execute \
            ("""UPDATE ir_sequence
                 SET prefix = replace(prefix, '(year)', '(fy)'),
                     suffix = replace(suffix, '(year)', '(fy)') 
               WHERE (prefix like '%(year)%' or  suffix like '%(year)%') 
                 AND id IN (SELECT sequence_main_id
                               FROM account_sequence_fiscalyear) ;""" 
            )
  
ir_sequence_installer()

# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#    Copyright (C) 2010-2010 Camptocamp Austria (<http://www.camptocamp.at>)
#    Copyright (C) 2011-2011 Swing Entwicklung betrieblicher Informationssysteme GmbH (<http://www.swing-system.com>)
#
#    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 osv import fields, osv

class ir_sequence_installer(osv.osv_memory):
    _name    = 'ir.sequence.installer'
    _inherit = 'res.config.installer'

    def execute(self, cr, uid, ids, context=None):

        cr.execute \
            ("""UPDATE ir_sequence
                 SET prefix = replace(prefix, '(year)', '(fy)'),
                     suffix = replace(suffix, '(year)', '(fy)') 
               WHERE (prefix like '%(year)%' or  suffix like '%(year)%') 
                 AND id IN (SELECT sequence_main_id
                               FROM account_sequence_fiscalyear) ;""" 
            )
  
ir_sequence_installer()

remove dead code