Odoo Help


Download a microsoft document action

Ramy Wafa
on 4/13/14, 10:46 AM 1,888 views

I want to implement the functionality of downloading an automatically generated word document. Similar to reports in the HR recruitment module. The functionality is available under Human resources -> recruitment -> Applications -> form view of any application on the top right side of the sheet you find the print interview button which downloads the survey.

I want a similar functionality however it should not be a report but a word document that is populated with data from the applicant such as his/her name date of applying, ... ect. I already have a python function that can populate Microsoft word documents with data from a given dictionary, but the main problem I am facing is how to make the generated document downloadable on click from the user. The document doesn't need to be associated with the applicant so there is no field for the document to be downloaded.




| 5 5 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 4/30/14, 11:25 AM

Using wizard we can make the generated document downloadable on click from the user.



from osv import fields, osv
import base64 class sample_data(osv.osv_memory): _name = "sample.data" _columns = { 'data': fields.binary('Export to File',readonly=True), 'filename': fields.char('File Name', size=128), } _defaults = {'filename' : 'sampleword.doc'} def action_sample_data(self, cr, uid, ids, context=None): this = self.browse(cr, uid, ids)[0] output = 'Sample Content Print in the word document' self.write(cr, uid, ids, {'data': base64.encodestring(output)}, context=context) return { 'type': 'ir.actions.act_window', 'res_model': 'sample.data', 'view_mode': 'form', 'view_type': 'form', 'res_id': this.id, 'views': [(False, 'form')], 'target': 'new', }


  <record id="view_sample_data_form" model="ir.ui.view">
        <field name="name">sample.data.form</field>
        <field name="model">sample.data</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Export">
              <group colspan="4" col="4">               
                 <button  icon="gtk-ok" name="action_sample_data"  string="Generate Data" type="object"/>                
               <field name="data"  filename="filename"/>

    <record id="action_generate_data" model="ir.actions.act_window">
        <field name="name">Data</field>
        <field name="res_model">sample.data</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
       <field name="view_id" ref="view_sample_data_form"/>
       <field name="target">new</field>
       <field name="context">{'model':'sample.data'}</field>

   <act_window name="Data"

After clicking the wizard button it will allows the download options in the wizard pop up itself.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 4/13/14, 10:46 AM
Seen: 1888 times
Last updated: 7/6/15, 7:59 AM