python - Formating related datetime field -
i have related datetime field
'expected_date' : fields.related('picking_id','date',type='datetime', relation='stock.picking', store=true, string="date"),
then want show field in report, want change format of field using code
'picking_date' : datetime.strftime(datetime.strptime(str(expected_date), '%y-%m-%d %h:%m:%s'),'%d-%m-%y'),
then got error
time data 'none' not match format '%y-%m-%d %h:%m:%s'
can show me did go wrong? i'm using openerp6
expected_date
none
str(expected_date)
returns string value "none"
, hence not match error.
you want
'picking_date' : (expected_date not none , datetime.strftime(datetime.strptime(str(expected_date), '%y-s%m-%d %h:%m:%s'),'%d-%m-%y') or 'none'),
Comments
Post a Comment