Skip to Content
Menu
This question has been flagged
2 Replies
15910 Views

When i run my code i got the error 'AttributeError: 'list' object has no attribute 'get''

    @api.onchange('custom_product_category_ids')

    def _get_selection(self):

        values = []

        prod_categ_ids = self.env['custom.product.category'].search([['id','=', self.custom_product_category_ids.id],])

        print(prod_categ_ids)

        for product_categ in prod_categ_ids:

            print(product_categ.id)

            print('pass')

            product_obj = self.env['custom.product.category'].browse(product_categ.id)

            values.append([str(product_obj.id), str(product_obj.categ_name)])

            print(values)

        return values



What is the problem ?


Avatar
Discard
Best Answer

Hi,

Please update this line

prod_categ_ids = self.env['custom.product.category'].search([['id','=', self.custom_product_category_ids.id],])

to

prod_categ_ids = self.env['custom.product.category'].search([('id', '=', self.custom_product_category_ids.id)])


and see whether it solves the issue or not.


Thanks

Avatar
Discard
Best Answer

Please correct this line.

prod_categ_ids = self.env['custom.product.category'].search([('id', '=', self.custom_product_category_ids.id)])

Avatar
Discard