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>

6 comments:

  1. Nice Blog.

    Its helpful for initials in Odoo. :)

    ReplyDelete
  2. @api.multi
    def print_demo_test_report(self):
    report_data = []
    report_val = {'name': self.name,'city': self.city}
    report_data.append(report_val)
    datas = {'partner': report_data}


    return self.env['report'].get_action(self, 'module name.report_template_id', data=datas)

    How fetch value in report from data??????????????

    ReplyDelete
  3. What should I do if I want to name the outgoing pdf? For example Quotation_SO230.pdf

    ReplyDelete