[IMP]: caldav: Improvement in export data wizard for binary field

bzr revid: rpa@tinyerp.com-20100326133310-jm2zsjxmoe7kam7q
This commit is contained in:
rpa (Open ERP)
2010-03-26 19:03:10 +05:30
parent 834ed9b185
commit 836e67c9fa
2 changed files with 13 additions and 12 deletions
+12 -12
View File
@@ -32,38 +32,38 @@ class calendar_event_export(osv.osv_memory):
"""
Export Calendar Event.
"""
def _process_export_ics(self, cr, uid, context):
def process_export_ics(self, cr, uid, ids, context):
"""
Get Default value for file_path field.
"""
model = context.get('model', 'basic.calendar')
model_obj = self.pool.get(model)
calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
#TODO: check why returns wrong value
return base64.encodestring(calendar)
def _process_export_ics_name(self, cr, uid, context):
calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
self.write(cr, uid, ids, {'file_path': base64.encodestring(calendar)})
return False
def default_get(self, cr, uid, fields, context):
"""
Get Default value for Name field.
"""
model = context.get('model', 'basic.calendar')
model_obj = self.pool.get(model)
calendar = model_obj.export_cal(cr, uid, context['active_ids'], context)
return 'OpenERP %s.ics' % (model_obj._description)
res = super(calendar_event_export, self).default_get( cr, uid, fields, context=context)
name = 'OpenERP %s.ics' % (model_obj._description)
if 'name' in fields:
res.update({'name': name})
return res
_name = "calendar.event.export"
_description = "Event Export"
_columns = {
'file_path':fields.binary('Save ICS file', filters='*.ics', required=True),
'file_path':fields.binary('Save ICS file', filters='*.ics', readonly=True),
'name':fields.char('File name', size=34, required=True, help='Save in .ics format')
}
_defaults = {
'name': _process_export_ics_name,
'file_path': _process_export_ics
}
calendar_event_export()
@@ -13,6 +13,7 @@
</group>
<separator string="" colspan="4" />
<group colspan="4" col="6">
<button name="process_export_ics" icon="gtk-execute" string="Genetate ics" type="object"/>
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
</group>
</form>