[IMP]: caldav: Improvement in export data wizard for binary field
bzr revid: rpa@tinyerp.com-20100326133310-jm2zsjxmoe7kam7q
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user