Sunday, 13 September 2015

QWEB Report in Odoo

Step: 1 Create menu for Report menu :
       <report
        id="action_report_id"
        model="model name"
        string="Report Name"
        report_type="qweb-pdf"
        name="module name.report_template_id"
        file="module name.report_template_id"
        />
Step 2 : Create .py file for call report template and method like this :
class custom_class_name(report_sxw.rml_parse):


    def __init__(self, cr, uid, name, context):
        super(custom_class_name, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
               'time': time,
        })



class test_report_class_name(osv.AbstractModel):
    _name = 'report.module_name.report_template_id'
    _inherit = 'report.abstract_report'
    _template = 'module_name.report_template_id'
    _wrapped_report_class = custom_class_name
Step: 3 Create template in xml file for report view like this :
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
    <data>
        <template id="report_template_id">
            <t t-foreach="docs" t-as="o">
                <div class="page">
                    <div class="row">
                        <div class="col-xs-6">
                             <span> Your Report View</span>
                        </div>
                    </div>              
                </div>
            </t>
        </template>
     </data>
  </openerp>