Merge branch '7.0' into 8.0 until 7318cd09

This commit is contained in:
Stéphane Bidoul
2014-12-03 19:11:19 +01:00
4 changed files with 58 additions and 1 deletions

View File

@@ -8,6 +8,9 @@ using the sequence.
The first time the sequence is used for a given fiscal year,
a specific fiscal year sequence starting at 1 is created automatically.
The module also replaces %(year)s by %(fy)s in the default prefix
for new journals, assuming it is a safer default.
Caveat
------
@@ -27,4 +30,4 @@ Author:
Contributors:
* Laetitia Gangloff (ACSONE)
* Laetitia Gangloff (ACSONE)

View File

@@ -24,3 +24,4 @@
##############################################################################
from . import ir_sequence
from . import account_journal

View File

@@ -0,0 +1,43 @@
# coding=utf-8
##############################################################################
#
# account_auto_fy_sequence module for Odoo
# Copyright (C) 2014 ACSONE SA/NV (<http://acsone.eu>)
# @author Laetitia Gangloff <laetitia.gangloff@acsone.eu>
#
# account_auto_fy_sequence is free software:
# you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License v3 or later
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# account_auto_fy_sequence 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 v3 or later for more details.
#
# You should have received a copy of the GNU Affero General Public License
# v3 or later along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm
class account_journal(orm.Model):
_inherit = "account.journal"
def create_sequence(self, cr, uid, vals, context=None):
""" Create new no_gap entry sequence for every new Joural
with fiscal year prefix
"""
seq_id = super(account_journal, self).create_sequence(cr, uid, vals,
context=context)
seq_obj = self.pool['ir.sequence']
seq = seq_obj.browse(cr, uid, seq_id, context=context)
prefix = seq.prefix.replace('%(year)s', '%(fy)s')
seq_obj.write(cr, uid, seq_id, {'prefix': prefix}, context=context)
return seq_id

View File

@@ -67,3 +67,13 @@ class TestAutoFYSequence(common.TransactionCase):
self.assertEqual(n, "SEQ/%s/1" % fiscalyear.code)
n = self.seq_obj._next(self.cr, self.uid, [seq_id], context)
self.assertEqual(n, "SEQ/%s/2" % fiscalyear.code)
def test_3(self):
""" Create journal and check the sequence attached to the journal """
aj_obj = self.registry('account.journal')
aj_id = aj_obj.create(self.cr, self.uid, {'name': 'sequence (test)',
'code': 'SQT',
'type': 'bank',
})
aj = aj_obj.browse(self.cr, self.uid, aj_id)
self.assertEqual(aj.sequence_id.prefix, 'SQT/%(fy)s/')