2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-01-27 00:19:55 +00:00
|
|
|
##############################################################################
|
2009-10-14 11:15:34 +00:00
|
|
|
#
|
2009-01-27 00:19:55 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2009-01-27 00:19:55 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# 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.
|
2009-01-27 00:19:55 +00:00
|
|
|
#
|
|
|
|
# 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
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2009-01-27 00:19:55 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# 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/>.
|
2009-01-27 00:19:55 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
|
|
from osv import fields,osv
|
|
|
|
|
|
|
|
class ir_sequence_fiscalyear(osv.osv):
|
|
|
|
_name = 'account.sequence.fiscalyear'
|
|
|
|
_rec_name = "sequence_main_id"
|
|
|
|
_columns = {
|
|
|
|
"sequence_id": fields.many2one("ir.sequence", 'Sequence', required=True, ondelete='cascade'),
|
|
|
|
"sequence_main_id": fields.many2one("ir.sequence", 'Main Sequence', required=True, ondelete='cascade'),
|
|
|
|
"fiscalyear_id": fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, ondelete='cascade')
|
|
|
|
}
|
2010-01-22 10:46:09 +00:00
|
|
|
|
|
|
|
_sql_constraints = [
|
|
|
|
('main_id', 'CHECK (sequence_main_id != sequence_id)', 'Main Sequence must be different from current !'),
|
|
|
|
]
|
|
|
|
|
2009-01-27 00:19:55 +00:00
|
|
|
ir_sequence_fiscalyear()
|
|
|
|
|
|
|
|
class ir_sequence(osv.osv):
|
|
|
|
_inherit = 'ir.sequence'
|
|
|
|
_columns = {
|
|
|
|
'fiscal_ids' : fields.one2many('account.sequence.fiscalyear', 'sequence_main_id', 'Sequences')
|
|
|
|
}
|
2010-01-29 10:53:56 +00:00
|
|
|
def get_id(self, cr, uid, sequence_id, test='id', context={}):
|
|
|
|
cr.execute('select id from ir_sequence where '+test+'=%s and active=%s', (sequence_id, True,))
|
2009-01-27 00:19:55 +00:00
|
|
|
res = cr.dictfetchone()
|
|
|
|
if res:
|
|
|
|
for line in self.browse(cr, uid, res['id'], context=context).fiscal_ids:
|
|
|
|
if line.fiscalyear_id.id==context.get('fiscalyear_id', False):
|
2010-01-29 10:53:56 +00:00
|
|
|
return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id", context=context)
|
2009-01-27 00:19:55 +00:00
|
|
|
return super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context)
|
|
|
|
ir_sequence()
|
|
|
|
|
|
|
|
|
2009-03-06 22:18:24 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|