Odoo Help


AttributeError: 'NoneType' object has no attribute 'search'

on 5/16/13, 7:25 PM 3,963 views

When i want to print a sale order, i have the error : AttributeError: 'NoneType' object has no attribute 'search'

i have created a custom module that overwrite the method create of a sale order, i think this is why i have this error, but i dont know why.. Any ideas ?


Please post code of your new function

on 5/16/13, 7:51 PM

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--

| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 5/19/13, 10:58 AM


variable section_pool is defined only in your "if" section with :

section_pool = self.pool.get('sale.order.section') #recuperation de l'objet section

but not in the "else" section.


On 5/16/13, 7:53 PM
    def create(self, cr, uid, vals, context=None):
    id = super(sale_order, self).create(cr, uid, vals, context) # creation du devis (et des lignes de commandes du devis)
    liste_numeros_section = [] # creation d'une liste vide qui contiendra tous les numeros de sections saisis dans la vue
    order_line_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', id), ('is_option', '=', False)], context=context) # recuperation de toutes les lignes du devis (qui ne sont pas des options)
    for i in self.pool.get('sale.order.line').browse(cr,uid,order_line_ids, context=context): # pour chaque ligne du devis
        if not(i.number_section in liste_numeros_section): # si nouveau numero de section, alors creation section + lien avec ligne de devis actuelle
            dict_section = {
                                'order_id': id,
                                'order_line': [(4, i.id)], # lier ligne du devis actuelle a la section (creation d'une relation)
                                'number': i.number_section,
            section_pool = self.pool.get('sale.order.section') #recuperation de l'objet section
            section_pool.create(cr,uid,dict_section, context=context)
        else: # si le numero de section existe deja, alors creation lien ligne du devis actuelle / section
            id_section = section_pool.search(cr,uid, [('number', '=', i.number_section), ('order_id' , '=', id)], context=context) #recupere section qui correspond a la ligne du devis
            dict_section = {
                                'order_line': [(4, i.id)], # lier ligne du devis actuelle a la section (creation d'une relation)
            section_pool.write(cr,uid,id_section,dict_section, context=context) #mise a jour de la section (cad ajout lien avec ligne devis)
    return id

everything seems correct. remove this function and try print a sale order .if ok try to keep your code by print.

on 5/16/13, 8:24 PM

dont post ur query in answer post it as comment

on 5/17/13, 3:28 AM

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.


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

0 follower(s)


Asked: 5/16/13, 7:25 PM
Seen: 3963 times
Last updated: 6/4/15, 1:59 AM