Hello, please help me, How to fix "NoneType' object has no attribute '__getitem__'" error



def get_lines(self, production):

product_lines = []

for bom in production:

    products = bom.product_id

    materials = bom.material_ids

    if not products:

        products = bom.product_tmpl_id.product_variant_ids

    for product in products:

        attributes = []

        for value in product.attribute_value_ids:

                attributes += [(,]

         result, result2 = bom.explode(product, 1)

         product_line = {'bom': bom,


                                        'materials': [],

                                        'lines': [], 'total': 0.0,

                                         'currency': self.env.user.company_id.currency_id,

                                          'product_uom_qty': bom.product_qty,

                                           'product_uom': bom.product_uom_id,

                                            'attributes': attributes}

                material_lines = [0]

               for material in materials:

                    material_line = {'product_id':material.product_id,

                                                'face_qty': material.face_qty,






                            print 'formula :', material_line.formula

                             product_line['materials'] += [material_line]

    return product_lines



        <t t-foreach="line[materials]" t-as="line_in">


                        <span t-esc="line_in[formula]"></span>




here is my log 

QWebException: 'NoneType' object has no attribute '__getitem__'

Traceback (most recent call last):

File "/home/delgertsetseg/workspace/odoo/odoo/addons/base/ir/ir_qweb/", line 315, in _compiled_fn

return compiled(self, append, values, options, log)

File "<template>", line 1, in template_1039_101

File "<template>", line 3, in body_call_content_100

File "<template>", line 4, in foreach_99

File "<template>", line 5, in body_call_content_98

TypeError: 'NoneType' object has no attribute '__getitem__'

Error to render compiling AST

TypeError: 'NoneType' object has no attribute '__getitem__'

Template: 1039

Path: /templates/t/t/t/t/div/table[4]/tbody/strong/t

Node: <t t-foreach="line[materials]" t-as="line_in">


<span t-esc="line_in[formula]"/>



How to fix this error