1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 from openerp.osv import fields, osv
25 class account_move(osv.osv):
26 _inherit = 'account.move'
29 'internal_sequence_number': fields.char('Internal Number', size=64, readonly=True, help='Internal Sequence Number'),
32 def post(self, cr, uid, ids, context=None):
33 obj_sequence = self.pool.get('ir.sequence')
34 res = super(account_move, self).post(cr, uid, ids, context=context)
36 for move in self.browse(cr, uid, ids, context=context):
37 if move.journal_id.internal_sequence_id:
38 seq_no = obj_sequence.next_by_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context)
40 self.write(cr, uid, [move.id], {'internal_sequence_number': seq_no})
44 class account_journal(osv.osv):
45 _inherit = "account.journal"
48 '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."),
52 class account_move_line(osv.osv):
53 _inherit = "account.move.line"
56 'internal_sequence_number': fields.related('move_id','internal_sequence_number', type='char', relation='account.move', help='Internal Sequence Number', string='Internal Number'),
60 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: