2010-11-03 08:26:39 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
2012-12-06 14:56:32 +00:00
from openerp . osv import fields , osv
2010-11-03 08:26:39 +00:00
class account_move ( osv . osv ) :
_inherit = ' account.move '
2010-11-10 06:07:22 +00:00
2010-11-03 08:26:39 +00:00
_columns = {
2014-07-06 14:44:26 +00:00
' internal_sequence_number ' : fields . char ( ' Internal Number ' ,
readonly = True , copy = False ,
help = ' Internal Sequence Number ' ) ,
2010-11-03 08:26:39 +00:00
}
2010-11-10 06:07:22 +00:00
2010-11-03 08:26:39 +00:00
def post ( self , cr , uid , ids , context = None ) :
obj_sequence = self . pool . get ( ' ir.sequence ' )
2010-11-10 06:07:22 +00:00
res = super ( account_move , self ) . post ( cr , uid , ids , context = context )
seq_no = False
2010-12-13 06:43:09 +00:00
for move in self . browse ( cr , uid , ids , context = context ) :
2010-11-26 10:38:44 +00:00
if move . journal_id . internal_sequence_id :
2011-09-29 13:22:54 +00:00
seq_no = obj_sequence . next_by_id ( cr , uid , move . journal_id . internal_sequence_id . id , context = context )
2010-11-03 08:26:39 +00:00
if seq_no :
2010-11-26 10:38:44 +00:00
self . write ( cr , uid , [ move . id ] , { ' internal_sequence_number ' : seq_no } )
2010-11-03 08:26:39 +00:00
return res
2010-11-10 06:07:22 +00:00
2010-11-03 08:26:39 +00:00
class account_journal ( osv . osv ) :
_inherit = " account.journal "
2010-11-10 06:07:22 +00:00
2010-11-03 08:26:39 +00:00
_columns = {
2010-11-26 10:28:30 +00:00
' internal_sequence_id ' : fields . many2one ( ' ir.sequence ' , ' Internal Sequence ' , help = " This sequence will be used to maintain the internal number for the journal entries related to this journal. " ) ,
2010-11-03 08:26:39 +00:00
}
2010-11-19 05:22:31 +00:00
2010-11-10 06:07:22 +00:00
2010-11-19 12:50:46 +00:00
class account_move_line ( osv . osv ) :
_inherit = " account.move.line "
_columns = {
2010-11-22 08:08:06 +00:00
' internal_sequence_number ' : fields . related ( ' move_id ' , ' internal_sequence_number ' , type = ' char ' , relation = ' account.move ' , help = ' Internal Sequence Number ' , string = ' Internal Number ' ) ,
2010-11-19 12:50:46 +00:00
}
2010-11-25 04:10:33 +00:00
2010-11-26 10:28:30 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: