This question has been flagged
2 Replies
9352 Views

I get an error when I try to run my module AttributeError: 'NoneType' object has no attribute 'name_search'

Below is my code,  please assist:

def _get_countries(self, cr, uid, context=None):

        cr.execute('SELECT res_country.code,res_country.name FROM res_country ORDER BY name')

        return cr.fetchall()

 

'nationality':fields.reference('Nationality', type='selection', selection=(_get_countries ), method=True),  ???

 

 

 

 

 

Avatar
Discard
Author

https://docs.google.com/a/digitaltreasure.co.bw/file/d/0B_BAgvBBQn_KMXFvZGtWaExmRDg/edit

try using function field,, field.function(type='selection')... update me if that solves the problem

This worked. Thanks for your response.

    def _get_countries(self, cr, uid, context=None):
        cr.execute('SELECT res_country.code,res_country.name FROM res_country ORDER BY name')
        return cr.fetchall()


'nationality':fields.selection(_get_countries,'Nationality',required=True),

On 10 November 2014 06:32, Baiju KS <baijuks@hotmail.com> wrote:

try using function field,, field.function(type='selection')... update me if that solves the problem

--
Baiju KS
Sent by OpenERP S.A. using Odoo about Forum Post AttributeError: 'NoneType' object has no attribute 'name_search'

Best Answer

try using function field,, field.function(type='selection')... update me if that solves the problem

def _get_countries(self, cr, uid, context=None):
        cr.execute('SELECT res_country.code , res_country.name FROM res_country ORDER BY name')
        return cr.fetchall()



'nationality':fields.selection(_get_countries,'Nationality',required=True),

 

 

Avatar
Discard

Is it possible to use this command------------ def _get_countries(self, cr, uid, context=None): #cr.execute('SELECT res_country.code , res_country.name FROM res_country ORDER BY name') cr.execute('SELECT res_partner.name from res_partner') return cr.fetchall()

Author Best Answer

This worked.  Baiju, Thanks for your response.

    def _get_countries(self, cr, uid, context=None):
        cr.execute('SELECT res_country.code , res_country.name FROM res_country ORDER BY name')
        return cr.fetchall()



'nationality':fields.selection(_get_countries,'Nationality',required=True),

Avatar
Discard