Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
9975 Представления

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),  ???

 

 

 

 

 

Аватар
Отменить
Автор

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'

Лучший ответ

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),

 

 

Аватар
Отменить

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()

Автор Лучший ответ

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),

Аватар
Отменить