Skip to Content
Menu
This question has been flagged
7 Replies
11802 Views

i am use odoo version 8

i want to create custom report in account module.

 in "account_report.xml"

<report

id="custom_report_all_invoice"

model="account.invoice"

string="Sekoo Report all invoice"

report_type="qweb-pdf"

name="account.partnerledger_sekoo_all"

attachment_use="False"

file="account.partnerledger_sekoo_all"

/>


in my "partnerledger_sekoo_all.py"


import time

import datetime

from dateutil.relativedelta import relativedelta

from openerp.osv import osv

from openerp.report import report_sxw


class partnerledger_sekoo_all_report_parser(report_sxw.rml_parse):

     def __init__(self, cr, uid, name, context):

         super(partnerledger_sekoo_all_report_parser, self).__init__(cr, uid, name, context=context)

         self.localcontext.update({

               'time': time,

               'lines': self.lines,

              'get_partners':self._get_partners,

              'hello_world': self._hello_world,

              'invoices': self.invoices,

            })

     def invoices(self):

         self.cr.execute(

            "SELECT * FROM account_move_line l ")

           res = self.cr.dictfetchall()

           sum = 0.0

           if self.initial_balance:

              sum = self.init_bal_sum

              for r in res:

                 sum += r['debit'] - r['credit']

                 r['progress'] = sum

               full_account.append(r)

         return full_account

     def _hello_world(self):

        return "Hello World!"


class partnerledger_sekoo_all(osv.AbstractModel):

     _name = 'report.partnerledger_sekoo_all'

    _inherit = 'report.abstract_report'

    _template = 'partnerledger_sekoo_all'

    _wrapped_report_class = partnerledger_sekoo_all_report_parser



in "partnerledger_sekoo_all.xml"


<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<template id="partnerledger_sekoo_all">

<t t-call="report.html_container">

<t t-call="report.internal_layout">

<div class="page">

<h2>Sekoo Partner Ledger all</h2>

<span t-esc="hello_world()"/>

</t>

</t>

</template>

</data>

</openerp>


i also make entry in __openerp.py__ of xml file

and in __init.py__ import partnerledger_sekoo_all_report_parser


but in template that not show anything,

it return error like

"'NoneType' object is not callable" while evaluating

'hello_world()'

how can i solve that please help

Avatar
Discard

Do you have 'report' in depends, in __openerp__py?

@Zbik i make entry of report.xml file in __openerp__.py it render template and not show any error but parser method hello_world() not accessible in .xml file please specify if anything else is required for parser in report also any detail doc for that

Best Answer

Hi @kartik

Your report name is 'account.partnerledger_sekoo_all' so you need to use it for the parser _template and _name in order to be used by Odoo. You could read a complete explanation and example at:

https://www.odoo.com/es_ES/forum/help-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244

Your case could be solved like:

class partnerledger_sekoo_all(osv.AbstractModel):

_name = 'report.account.partnerledger_sekoo_all'

_inherit = 'report.abstract_report'

_template = 'account.partnerledger_sekoo_all'

_wrapped_report_class = partnerledger_sekoo_all_report_parser
Avatar
Discard
Author

thank it wroks for me now i want to get all invoice objects with invoice lilne how can i get that in report.xml through parser file in odoo report

Don't you have a function in the parser for that?. In the link above there is examples of how to do it

Author

i want to get all invoice with invoice line in odoo report i try with this def invoices(self): self.cr.execute( "SELECT * FROM account_move_line l ") res = self.cr.dictfetchall() return res but it gives all record i want to get invoice list customer wise

You could vote up if your post issue is solved

Best Answer

In __openerp__.py, try this

'depends': ['account','report']

UPDATE:

You comment lines and test again:

'lines': self.lines,

'get_partners':self._get_partners,

'invoices': self.invoices,


Avatar
Discard
Author

in accounts/__openerp__.py line already exist 'depends' : ['base_setup', 'product', 'analytic', 'board', 'edi', 'report'], after i add 'depends' : ['base_setup', 'product', 'analytic', 'board', 'edi', 'report','account'], so it return error 500: Internal Server Error Error Error message: account.invoice in log file it shows 2015-10-16 13:15:05,288 8204 ERROR bitnami_openerp openerp.addons.document.content_index: Cannot determine mime type. Traceback (most recent call last): File "C:\Bitnami\odoo-8.0-8\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\addons\document\content_index.py", line 167, in doIndex pop = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE) File "C:\Bitnami\odoo-8.0-8\python\lib\subprocess.py", line 709, in __init__ errread, errwrite) File "C:\Bitnami\odoo-8.0-8\python\lib\subprocess.py", line 957, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified 2015-10-16 13:15:07,450 8204 ERROR bitnami_openerp openerp.addons.document.content_index: Cannot determine mime type. Traceback (most recent call last): File "C:\Bitnami\odoo-8.0-8\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\addons\document\content_index.py", line 167, in doIndex pop = Popen(['file','-b','--mime',fname], shell=False, stdout=PIPE) File "C:\Bitnami\odoo-8.0-8\python\lib\subprocess.py", line 709, in __init__ errread, errwrite) File "C:\Bitnami\odoo-8.0-8\python\lib\subprocess.py", line 957, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified 2015-10-16 13:15:18,243 8204 INFO bitnami_openerp openerp.service.common: successful login from 'admin' using database 'bitnami_openerp' 2015-10-16 09:15:43,584 8988 WARNING bitnami_openerp openerp.addons.base.ir.ir_cron: Model `automatic.workflow.job` does not exist. 2015-10-16 09:16:43,622 8988 WARNING bitnami_openerp openerp.addons.base.ir.ir_cron: Model `automatic.workflow.job` does not exist.

You create own custom module with this report and with this depends. If you only modify module account (it is NOT recommended), probably other error exist in code. Show your log file. PS. for new api in v8 see "Custom reports" - https://www.odoo.com/documentation/8.0/reference/reports.html

answer updated

Related Posts Replies Views Activity
0
Oct 15
2707
1
Sep 15
5538
2
Oct 22
26714
0
Nov 22
5729
1
Mar 16
5618