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 we use python parser file in odoo report

By
kartik
on 10/16/15, 7:40 AM 1,955 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

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

zbik
on 10/16/15, 7:59 AM

@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

kartik
on 10/17/15, 9:17 PM
0

Axel Mendoza

--Axel Mendoza--
10195
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 10/17/15, 4:55 AM

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

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

kartik
on 10/19/15, 2:57 AM

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

Axel Mendoza
on 10/19/15, 3:25 AM

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

kartik
on 10/20/15, 5:47 AM

You could vote up if your post issue is solved

Axel Mendoza
on 10/21/15, 10:29 PM
0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 10/16/15, 8:33 AM

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,


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.

kartik
on 10/16/15, 9:20 AM

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

zbik
on 10/16/15, 9:42 AM

answer updated

zbik
on 10/16/15, 1:26 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

2 follower(s)

Stats

Asked: 10/16/15, 7:40 AM
Seen: 1955 times
Last updated: 10/19/15, 2:57 AM