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

cannot execute the function [Closed]

By
priyankahdp
on 3/14/13, 5:15 AM 1,273 views

The Question has been closed

by
priyankahdp
on 04/20/2013 03:20:42

Here is my class and methods. I just wrote for get records and need to print them.but when run openerp in debug mode.its not worked & not go for that method also.& also need to clarify the fetching methods OpenERP 7

class namelistupdate(osv.osv):
    def _mytest_query(self, cr, uid, ids, name, args, context=None):
        print ('here is demo sql query function result ')
        cr.execute("""SELECT module,(id*5000)as result FROM ir_model_data WHERE id=1""")
        res = cr.dictfetchall()
        print ('here is demo sql query function result ')
        print (res)

    def _invoiced_rate(self, cr, uid, ids, name, args, context):
        self._mytest_query(cr, uid, ids, name, args, context)
        amount_untaxed = 1
        record_id = ids[0]
        res = {record_id: 0.0}
        if amount_untaxed == 0:
            res[record_id] = 100.0
        else:
            res[record_id] = 50.0
        return res

    _name = "checkroll.namelist.update"
    _description = "This table is for keeping Name list updates"
    _columns = {        
        'date': fields.date("Date"),
        'val': fields.function(_invoiced_rate, method=True, type='float', string='Test', store=True),
    }

namelistupdate()

now not a error .but out put as

here is demo sql query function result 
here is demo sql query function result 
[]

its need to be as

| base | 5000 |

You should call self._mytest_query not self.mytest_query

tvazac
on 3/14/13, 6:36 AM

thanks..but now error says TypeError: _mytest_query() takes exactly 7 arguments (8 given)

update in post

priyankahdp
on 3/14/13, 6:46 AM

You are giving self as an attribute... remove it from your call.

self._mytest_query(self, cr, uid, ids, name, args, context)

should be

self._mytest_query(cr, uid, ids, name, args, context)
Camptocamp SA
on 3/14/13, 6:56 AM

thanks now its ok.but out put not come.post edited above if i enter sql in postgre sql then it works perfectly

priyankahdp
on 3/14/13, 7:23 AM

I am getting result [{'result': 5000, 'module': u'base'}] I copied your code and it's working. I don't know why it's don't work for you. Are you forgot any thing to mention ? Or there is a emptyTable.

Parth Gajjar
on 3/14/13, 8:00 AM

yeah ok its worked perfectly...thanks a lot when we change a xml file need to press update module in settings.but when we change a python code then need to restart the server & relogging after update..then modification will shown to us :-)

priyankahdp
on 3/14/13, 8:06 AM

hmmmm..... you forgot that :P

Parth Gajjar
on 3/14/13, 8:17 AM

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 3/14/13, 5:15 AM
Seen: 1273 times
Last updated: 3/16/15, 8:10 AM