Odoo Help

0

NoneType' object is not callable" while evaluating

By
Ranga Dharmapriya
on 10/28/15, 12:39 AM 3,884 views

Hello,

I'm try to create Invoive copy receipt from POS screesn. but when I try to print bill I got this error.


NoneType' object is not callable" while evaluating 'get_journal_amt(o)' 


 import time

from openerp.osv import osv

from openerp.report import report_sxw

def titlize(journal_name):
    words = journal_name.split()
    while words.pop() != 'journal':
        continue
    return ' '.join(words)

class family_order(report_sxw.rml_parse):

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

        super(family_order, self).__init__(cr, uid, name, context=context)
        user = self.pool['res.users'].browse(cr, uid, uid, context=context)
        partner = user.company_id.partner_id
        self.localcontext.update({
            'time': time,
            # 'disc': self.discount,
            'net_amount': self._netamount,
            'get_journal_amt': self._get_journal_amt,
            # 'get_journal_amt': self._get_journal_amt,
            'address': partner or False,
            'titlize': titlize
        })


def _netamount(self):
 res = {'name': 'hello'} return res def _get_journal_amt(self, order_id): data={} sql = """ select aj.name,absl.amount as amt from account_bank_statement as abs LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id LEFT JOIN account_journal as aj ON aj.id = abs.journal_id WHERE absl.pos_statement_id =100""" self.cr.execute(sql, order_id) data = self.cr.dictfetchall() return data class bill_copy_report(osv.AbstractModel): _name = 'report.point_of_sale.bill_copy' _inherit = 'report.abstract_report' _template = 'point_of_sale.bill_copy' _wrapped_report_class = family_order # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # -*- coding: utf-8 -*-
##############################################################################


<?xml version="1.0" encoding="utf-8"?> 
<openerp>
<data>
<template id="bill_copy">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<div class="page">
<div class="row">
<div class="col-xs-12 text-center">
<span t-field="o.table_id"/>
Hello
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th class="text-right">Quantity</th>
<th class="text-right">Price</th>
</tr>
</thead>
<!--<tbody>-->
<!--&lt;!&ndash;<tr t-foreach ="o.lines" t-as="line">&ndash;&gt;-->
<!--&lt;!&ndash;<td><span t-field="line.name"/></td>&ndash;&gt;-->
<!--&lt;!&ndash;</tr>&ndash;&gt;-->

<!--<tr t-foreach="net_amount()" t-as="d">-->
<!--<td>-->
<!--<span t-esc="d['product_id']"/>-->
<!--</td>-->
<!--</tr>-->

<!--</tbody>-->
<tbody>
<tr t-foreach="get_journal_amt(o)" t-as="d">
<td>
<span t-esc="d['name']"/>
</td>
<td>
<span t-esc="formatLang(d['amt'], currency_obj=res_company.currency_id)"/>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</t>
</t>
</template>
</data>
</openerp>


Anyone know how to resolve this ?

Thank you...

2
Axel Mendoza
On 10/28/15, 2:57 AM

You have two options to get it fixed:

1- Rename your template id to be:

<template id="point_of_sale.bill_copy">

or

2- Change this to match report name/id:

class bill_copy_report(osv.AbstractModel):
_name = 'report.bill_copy'
_inherit = 'report.abstract_report'
_template = 'bill_copy'
_wrapped_report_class = family_order

See more 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

Axel Mendoza
on 10/28/15, 2:58 AM
2
Akhil P Sivan
On 10/28/15, 3:04 AM

Hi,

That means your function _get_journal_amt() is not returning anything as something wrong with the query or execute command.

Why are you passing order_id in self.cr.execute(), as you are not using that in your sql statement:

def _get_journal_amt(self, order_id):
data={}
sql = """ select aj.name,absl.amount as amt from account_bank_statement as abs
LEFT JOIN account_bank_statement_line as absl ON abs.id = absl.statement_id
LEFT JOIN account_journal as aj ON aj.id = abs.journal_id
WHERE absl.pos_statement_id =100"""
self.cr.execute(sql, order_id)
data = self.cr.dictfetchall()
return data

Try without order_id and also ensure your query is correct. Print data on terminal and check whether you are getting the records with your query.

About This Community

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

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 10/28/15, 12:39 AM
Seen: 3884 times
Last updated: 10/28/15, 3:44 AM