mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
Merge pull request #95 from acsone/7.0-account_auto_fy_sequence_imp-lga
account_auto_fy_sequence : When create journal, use fy instead of year in the sequence
This commit is contained in:
@@ -42,6 +42,9 @@
|
||||
initialize it's next number to the correct value.
|
||||
For this reason, the module will forbid the user to change
|
||||
a sequence from %(year)s to %(fy)s if it's next number is > 1.
|
||||
|
||||
The module also replaces %(year)s by %(fy)s in the default prefix
|
||||
for new journals, assuming it is a safer default.
|
||||
""",
|
||||
'author': 'ACSONE SA/NV',
|
||||
'website': 'http://acsone.eu',
|
||||
|
||||
@@ -24,3 +24,4 @@
|
||||
##############################################################################
|
||||
|
||||
from . import ir_sequence
|
||||
from . import account_journal
|
||||
|
||||
43
account_auto_fy_sequence/models/account_journal.py
Normal file
43
account_auto_fy_sequence/models/account_journal.py
Normal 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
|
||||
@@ -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/')
|
||||
|
||||
Reference in New Issue
Block a user