Odoo Help

Welcome!

This community 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.

0

how to add multi records in webkit report

By
Muaz
on 12/29/13, 6:06 PM 2,145 views

I made a webkit report, but when I print it, I found in PDF some fields not show. Error:

  browse_record(account. period,13)
  browse_record(res.company,1)
 browse_record(account.journal ,9)

How to use self.pool.get(' ') ?

My report class:

class exam_report_webkit_html(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(exam_report_webkit_html, self).__init__(cr, uid, name, context=context) self.pool = pooler.get_pool(self.cr.dbname) self.cursor = self.cr

company_obj = self.pool.get('res.company')

company_id = company_obj._company_default_get(self.cr, uid, 'res.users', context=context)
company = company_obj.browse(self.cr, uid, company_id, context=context)
self.localcontext.update({
    'time': time,
    'cr':cr,
    'uid': uid,
    })

def print_report(self, cr, uid, ids, context=None): # assert len(ids) == 1 period_obj=self.pool.get("account.period") period_ids=period_obj.build_ctx_periods(self.cursor, self.uid, start_period.id, stop_period.id) domain = [ ('period_id', 'in', period_ids), ] datas = { 'ids': period_ids, 'model': 'account.period', 'form': {} } return { 'type': 'ir.actions.report.xml', 'report_name': 'taskmng.report', 'datas': datas }
report_sxw.report_sxw('report.webkitexam', 'account.move', 'addons/test/report/exam_report_webkit_html.mako', parser=exam_report_webkit_html)

0

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 12/30/13, 9:01 AM

Your mako file must be like this:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>

</head>
<body>
    <p align="center" font-size="8">exam mako</p>
    <table dir="rtl" align="center" border="1" >

        <tr align="right">
            <th> journal_id</th>
            <th>date</th>
            <th>period_id</th>
            <th>ref</th>
            <th>company_id</th>
            <th>amount</th>
            <th>parent_id</th>
        </tr>

        %for o in objects :
        <tr>
            <td>${ o.journal_id.name}</td>
            <td>${o.date }</td>
            <td>${o.period_id.name}</td>
            <td>${ o.ref }</td>
            <td>${ o.company_id.name}</td>
            <td>${ o.amount}</td>
        </tr>
        %endfor

    </table> 
    </body>
 </html>

thanx sooooooooooooooooooooooo much

Muaz
on 12/30/13, 5:56 PM
0
Muaz
On 12/30/13, 10:35 AM

my error: `

browse_record(account. period,13)
browse_record(res.company,1)
browse_record(account.journal ,9)

please show my code, and tell me what can i do,

on my folder addons\exam:

exam.py:

from osv import fields, osv
import time
class exam(osv.osv):
_name = 'account.move.line'
_inherit = 'account.move.line'
_description = 'Simple accountiec'
_columns = {
    'parent_id': fields.many2one('hr.department', 'Parent Department', select=True),
    }
 exam()

addons\exam\report:

exam_report_webkit_html.py:

class exam_report_webkit_html(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
    super(exam_report_webkit_html, self).__init__(cr, uid, name, context=context)
    self.pool = pooler.get_pool(self.cr.dbname)
    self.cursor = self.cr

    period_obj= self.pool.get('account.account.period').browse(cr, uid, uid).period_id

    company_obj = self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).name

    self.localcontext.update({
        'time': time,
        'cr':cr,
        'uid': uid,
        })

report_sxw.report_sxw('report.webkitexam',
                  'account.move',
                  'addons/test/report/exam_report_webkit_html.mako', parser=exam_report_webkit_html)

exam_report_webkit_htm.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <report 
        auto="False"
        id="exam_report_webkit_html"
        model="account.move"
        name="account.move"
        file="exam/report/exam_report_webkit_html.mako"
        string="order"
        report_type="webkit"
        webkit_header="report_webkit.ir_header_webkit_basesample0"/>
</data>
</openerp>

exam_report.mako

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>

</head>
<body>
    <p align="center" font-size="8">exam mako</p>
    <table dir="rtl" align="center" border="1" >

        <tr align="right">
            <th> journal_id</th>
            <th>date</th>
            <th>period_id</th>
            <th>ref</th>
            <th>company_id</th>
            <th>amount</th>
            <th>parent_id</th>
        </tr>

        %for o in objects :
        <tr>
            <td>${ o.journal_id}</td>
            <td>${o.date }</td>
            <td>${o.period_id}</td>
            <td>${ o.ref }</td>
            <td>${ o.company_id}</td>
            <td>${ o.amount}</td>
        </tr>
        %endfor

    </table> 
    </body>
 </html>

Answer edited

GH Mediacloud, Grover Menacho
on 12/30/13, 4:42 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 12/29/13, 6:06 PM
Seen: 2145 times
Last updated: 3/16/15, 8:10 AM