Sequences in Openerp
In openerp sequences we can insert current year with century as suffix or prefix as following:
Code:
/%(year)s
I need to get the fiscal year as suffix in the sequence. Is there any possible way?
for eg: PO/0001/2012-2013
_________________
Regards,
Nightfury
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello,
Happy to help you.
Right now OpenERP is supporting only YEAR option for suffix which will be in 4 later.
This is the code written in python as:
'year': time.strftime('%Y', t) # will result current year string format.
So if you write %(year)s, then '2012' will be answer.
If you want to modify it, then you have to add in ir.sequence something like this:
'fiscal_year' = current year + "-" + next year (which you can generate by converting in integer)
So, %(financial_year)s = '2012-2013'
Its working, I have tried this.
Thanks,
IntellecTSeed Technologies.
www.intellectse
Revision history for this message
|
#2 |
were should i edit in ir.sequence sir?
Revision history for this message
|
#3 |
Hello,
In ir.sequence file, you have to make changes in "_interpolation
You can make calculation above return dictionary, and then whatever result is there, you can use it as fiscal_year.
Thanks,
IntellecTSeed Technologies
<email address hidden>
Revision history for this message
|
#4 |
you mean ir.sequence.py file?
Revision history for this message
|
#6 |
this is my ir.sequence.py file can u just help me with the coding u done?
pease
code:
# -*- coding: utf-8 -*-
#######
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://
#
# This program is free software: you can redistribute it and/or modify
# 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.
#
# 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
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://
#
#######
import time
from osv import fields,osv
import pooler
class ir_sequence_
_name = 'ir.sequence.type'
_order = 'name'
_columns = {
'name': fields.
'code': fields.
}
ir_sequence_type()
def _code_get(self, cr, uid, context={}):
cr.
return cr.fetchall()
class ir_sequence(
_name = 'ir.sequence'
_order = 'name'
_columns = {
'name': fields.
'code': fields.
'active': fields.
'prefix': fields.
'suffix': fields.
'padding' : fields.
}
_defaults = {
'active': lambda *a: True,
'padding' : lambda *a : 0,
}
def _process(self, s):
return (s or '') % {
'y': time.strftime(
'doy': time.strftime(
'woy': time.strftime(
'h24': time.strftime(
'h12': time.strftime(
'min': time.strftime(
'sec': time.strftime(
}
def get_id(self, cr, uid, sequence_id, test='id', context=None):
assert test in ('code','id')
company_ids = self.pool.
res = cr.dictfetchone()
if res:
if res['number_next']:
else:
return False
def get(self, cr, uid, code):
return self.get_id(cr, uid, code, test='code')
ir_sequence()
Revision history for this message
|
#7 |
Hello,
You can apply this patch.
def _interpolation_
t = time.localtime() # Actually, the server is always in UTC.
+
+ current = int(time.
+ next = int(time.
+ fiscal_year = str(current) + '-' + str(next)
+
return {
+ 'fiscal_year': fiscal_year,
'day': time.strftime('%d', t),
Revision history for this message
|
#8 |
hello IntellecTSeed Technologies (intellectseed) ,
"Hello,
You can apply this patch.
def _interpolation_
t = time.localtime() # Actually, the server is always in UTC.
+
+ current = int(time.
+ next = int(time.
+ fiscal_year = str(current) + '-' + str(next)
+
return {
+ 'fiscal_year': fiscal_year,
'day': time.strftime('%d', t),"
i applyed the above code you have sujjested
but it raised a key error in my terminal. the error is as follows:
[2012-07-13 00:40:41,
Traceback (most recent call last):
File "workspace/
return f(self, dbname, *args, **kwargs)
File "workspace/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "workspace/
return getattr(object, method)(cr, uid, *args, **kw)
File "workspace/
defaults[f] = self._defaults[
File "workspace/
'name': lambda obj, cr, uid, context: obj.pool.
File "workspace/
return self.get_id(cr, uid, code, test='code')
File "workspace/
context=
File "workspace/
return self._process(
File "workspace/
'sec': time.strftime(
KeyError: u'fiscal_year'
the below given is my code:
code:
# -*- coding: utf-8 -*-
#######
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-TODAY OpenERP S.A. <http://
#
# This program is free software: you can redistribute it and/or modify
# 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.
#
# 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
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://
#
#######
import time
from osv import fields,osv
import pooler
class ir_sequence_
_name = 'ir.sequence.type'
_order = 'name'
_columns = {
'name': fields.
'code': fields.
}
ir_sequence_type()
def _code_get(self, cr, uid, context={}):
cr.
return cr.fetchall()
class ir_sequence(
_name = 'ir.sequence'
_order = 'name'
_columns = {
'name': fields.
'code': fields.
'active': fields.
'prefix': fields.
'suffix': fields.
'padding' : fields.
}
_defaults = {
'active': lambda *a: True,
'padding' : lambda *a : 0,
}
def _process(self, s):
return (s or '') % {
'y': time.strftime(
'doy': time.strftime(
'woy': time.strftime(
'h24': time.strftime(
'h12': time.strftime(
'min': time.strftime(
'sec': time.strftime(
}
def get_id(self, cr, uid, sequence_id, test='id', context=None):
assert test in ('code','id')
company_ids = self.pool.
res = cr.dictfetchone()
if res:
if res['number_next']:
else:
return False
def _interpolation_
t = time.localtime() # Actually, the server is always in UTC.
current = int(time.
next = int(time.
return {
'day': time.strftime('%d', t),
}
def get(self, cr, uid, code):
return self.get_id(cr, uid, code, test='code')
ir_sequence()
# vim:expandtab:
if you dont mind an you just paste the ir.sequence.py code of yours so that i can refer mine with yours. please help as soon as possible
Revision history for this message
|
#9 |
someone please help...
Revision history for this message
|
#10 |
Can you help with this problem?
Provide an answer of your own, or ask Pravitha V for more information if necessary.