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

"Field 'get' does not exist in object 'browse_record(costcentre_asset, 2)'"

By
A V
on 10/1/13, 5:40 AM 2,967 views

The following error happened on the following

_columns = {
    'logusercst': fields.function(_hrlogcstget, method=True,string='Current user',type='char'),
}

and the function is like this ,

def _hrlogcstget(self, cr, uid, ids, field_name, arg, context=None):#

    user_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
    emp = self.pool.get('hr.employee')
    empobj = emp.browse(cr, uid, user_ids[0])
    res3=empobj.cost_centre
    return res3

and when i tried to add this functional field on the xml , it created the error

<field name="employee_id" position="after">
                                   <field name="logusercst" />             
                     </field>

Error is like this

Server Traceback (most recent call last):

File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server\openerp\addons\web\session.py", line 89, in send File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\netsvc.py", line 292, in dispatch_rpc File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\service\web_services.py", line 626, in dispatch File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\osv.py", line 188, in execute_kw File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\osv.py", line 131, in wrapper File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\osv.py", line 197, in execute File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\osv.py", line 185, in execute_cr File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\orm.py", line 3604, in read File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\orm.py", line 3724, in _read_flat File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\fields.py", line 1139, in get File "D:\Program Files\OpenERP 7.0-20130630-231044\Server\server.\openerp\osv\orm.py", line 486, in __getattr__ AttributeError: "Field 'get' does not exist in object 'browse_record(costcentre_asset, 2)'"

1

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 10/1/13, 8:10 AM

Your function must be:

def _hrlogcstget(self, cr, uid, ids, field_name, arg, context=None):
    user_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
    emp = self.pool.get('hr.employee')
    empobj = emp.browse(cr, uid, user_ids[0])
    res3=empobj.cost_centre
    result = {}
    for id in ids:
        result[id] = res3
    return result

Thank You :) ,

A V
on 10/1/13, 10:21 AM

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: 10/1/13, 5:40 AM
Seen: 2967 times
Last updated: 3/16/15, 8:10 AM