1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 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 ##############################################################################
24 from osv import fields,osv
26 class ir_sequence_fiscalyear(osv.osv):
27 _name = 'account.sequence.fiscalyear'
28 _rec_name = "sequence_main_id"
30 "sequence_id": fields.many2one("ir.sequence", 'Sequence', required=True, ondelete='cascade'),
31 "sequence_main_id": fields.many2one("ir.sequence", 'Main Sequence', required=True, ondelete='cascade'),
32 "fiscalyear_id": fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, ondelete='cascade')
34 ir_sequence_fiscalyear()
36 class ir_sequence(osv.osv):
37 _inherit = 'ir.sequence'
39 'fiscal_ids' : fields.one2many('account.sequence.fiscalyear', 'sequence_main_id', 'Sequences')
41 def get_id(self, cr, uid, sequence_id, test='id=%s', context={}):
42 cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,))
43 res = cr.dictfetchone()
45 for line in self.browse(cr, uid, res['id'], context=context).fiscal_ids:
46 if line.fiscalyear_id.id==context.get('fiscalyear_id', False):
47 return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id=%s", context=context)
48 return super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context)
52 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: