根据身份证计算生日、年龄、性别,欢迎大家讨论和补充
-
#计算生日、年龄、性别
def onchange_card( self, cr, uid, ids, name, args, context=None):
cut=self.browse(cr,uid, ids,context)
ret={}
for les in cut:
ret[les.id]={
'birthday':'',
'age':'',
'gender':''
}
if (les['is_company']==False) and (les['card']!=False):
a=les.card[6:14]
ret[les.id]['birthday']=a
b= les.card[6:10]
c=gmtime()[0]
now_=int(c)
bir_=int(b)
d=now_-bir_
s=str(d)
ret[les.id]['age']=s
sex = int(les.card[16:17])
if sex/2==0:
ret[les.id]['gender']='女'
else:
ret[les.id]['gender']='男'
return ret