Aide

0

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

Avatar
delgertsetseg

 @api.multi

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 += [(value.attribute_id.name, value.name)]

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

         product_line = {'bom': bom,

                                        'name': product.name,

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

                                                'color_id':material.color_id,

                                                'print_side':material.print_side,

                                                'papercut_id':material.papercut_id.cut_image,

                                                'formula':material.formula,

                                            }

                            print 'formula :', material_line.formula

                             product_line['materials'] += [material_line]

    return product_lines

//////////////xml///////////////

<strong>

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

                <tr>

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

                </tr>

        </t>

</strong>

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/qweb.py", 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">

<tr>

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

</tr>

</t>


How to fix this error

Avatar
Discard