* Add improvement into sequence variable
 * new variable available
 ** %(y)s : Year without century (ex 08)
 ** %(doy)s : day of the year
 ** %(woy)s : week of the year  
 ** %(weekday)s : day of the week (ex 0 -> Monday)
 ** %(h24)s : Hour [00->24]
 ** %(h12)s : Hour [00->12]
 ** %(min)s : Minutes
 ** %(sec)s : secondes

bzr revid: christophe.chauvet@syleam.fr-20081122000533-mlbpqulfrnxylove
This commit is contained in:
Christophe Chauvet
2008-11-22 01:05:33 +01:00
parent f71e08d649
commit 82dda1fb71
2 changed files with 33 additions and 4 deletions
+20 -3
View File
@@ -70,9 +70,26 @@
<field name="number_increment"/>
<field name="number_next"/>
<separator colspan="4" string="Legend (for prefix, suffix)"/>
<label colspan="4" string="Year: %%(year)s"/>
<label colspan="4" string="Month: %%(month)s"/>
<label colspan="4" string="Day: %%(day)s"/>
<group col="8" colspan="4">
<group>
<label colspan="4" string="Year with century: %%(year)s"/>
<label colspan="4" string="Year without century: %%(y)s"/>
<label colspan="4" string="Month: %%(month)s"/>
<label colspan="4" string="Day: %%(day)s"/>
</group>
<group>
<label colspan="4" string="Day of the year: %%(doy)s"/>
<label colspan="4" string="Week of the year: %%(woy)s"/>
<label colspan="4" string="Day of the week (0:Monday): %%(weekday)s"/>
</group>
<group>
<label colspan="4" string="Hour 00->24: %%(h24)s"/>
<label colspan="4" string="Hour 00->12: %%(h12)s"/>
<label colspan="4" string="Minute: %%(min)s"/>
<label colspan="4" string="Seconde: %%(sec)s"/>
</group>
</group>
<separator colspan="4" string=""/>
</form>
</field>
</record>
+13 -1
View File
@@ -55,7 +55,19 @@ class ir_sequence(osv.osv):
}
def _process(self, s):
return (s or '') % {'year':time.strftime('%Y'), 'month': time.strftime('%m'), 'day':time.strftime('%d')}
return (s or '') % {
'year':time.strftime('%Y'),
'month': time.strftime('%m'),
'day':time.strftime('%d'),
'y': time.strftime('%y'),
'doy': time.strftime('%j'),
'woy': time.strftime('%W'),
'weekday': time.strftime('%w'),
'h24': time.strftime('%H'),
'h12': time.strftime('%I'),
'min': time.strftime('%M'),
'sec': time.strftime('%S'),
}
def get_id(self, cr, uid, sequence_id, test='id=%d'):
cr.execute('select id,number_next,number_increment,prefix,suffix,padding from ir_sequence where '+test+' and active=True FOR UPDATE', (sequence_id,))