2010-11-23 10:46:33 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# 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 account_sequence_installer ( osv . osv_memory ) :
_name = ' account.sequence.installer '
_inherit = ' res.config.installer '
_columns = {
' internal_sequence ' : fields . many2one ( ' ir.sequence ' , ' Internal Sequence ' , help = " This sequence will be used on Journals to maintain internal number for accounting entries. " ) ,
}
def _get_internal_sequence ( self , cr , uid , context ) :
2010-11-24 07:29:23 +00:00
mod_obj = self . pool . get ( ' ir.model.data ' )
result = mod_obj . get_object_reference ( cr , uid , ' account_sequence ' , ' internal_sequence_journal ' )
2010-11-24 12:37:51 +00:00
res = result and result [ 1 ] or False
2010-11-24 07:29:23 +00:00
return res
2010-11-23 10:46:33 +00:00
def execute ( self , cr , uid , ids , context ) :
if context is None :
context = { }
res = super ( account_sequence_installer , self ) . execute ( cr , uid , ids , context = context )
jou_obj = self . pool . get ( ' account.journal ' )
obj_sequence = self . pool . get ( ' ir.sequence ' )
2010-11-24 07:29:23 +00:00
journal_ids = jou_obj . search ( cr , uid , [ ] )
2010-11-23 10:46:33 +00:00
for line in self . browse ( cr , uid , ids ) :
for journal in jou_obj . browse ( cr , uid , journal_ids ) :
if not journal . internal_sequence :
2010-11-24 12:37:51 +00:00
for seq in obj_sequence . browse ( cr , uid , [ line . internal_sequence . id ] ) :
2010-11-23 10:46:33 +00:00
if seq . id :
jou_obj . write ( cr , uid , [ journal . id ] , { ' internal_sequence ' : seq . id } )
return res
_defaults = {
2010-11-23 11:01:01 +00:00
' internal_sequence ' : _get_internal_sequence
}
2010-11-23 10:46:33 +00:00
account_sequence_installer ( )
2010-11-23 11:01:01 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: