python - Lines Functional values how to shows before saving the record -


openerp 7 based on requirement sale order lines remaining days calculate start date minus today @ times. functional field , on_change function used:-

def _remaining_days(self, cr, uid, ids, field_name, arg, context=none):     res = {}     if not ids:         return {}     val in self.browse(cr, uid, ids, context=context):         result = datetime.datetime.strptime(val.start_date, '%y-%m-%d') - datetime.datetime.strptime(current_date, '%y-%m-%d')         res[val.id] = result.days     return res  'remaining_days': fields.function(_remaining_days, method=true, string='remaining days', type='integer'),   def onchange_holddays(self, cr, uid, ids, start_date, context=none):     result = {}       context = context or {}     if release_date:         current_date = time.strftime('%y-%m-%d')         remaining = datetime.datetime.strptime(release_date, '%y-%m-%d') - datetime.datetime.strptime(current_date, '%y-%m-%d')         result['remaining_days'] = remaining.days                     return {'value': result} 

in order lines remaining days values not updated automatically. once save main sale order record lines remaining days value updated. how shows remaining days values in list view before saving record. kno

function field executed when save record, you'll not able values before that. either use on_change event , display values on run time or use wizard accept such data , save on main form.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -