Title: can't adapt type 'product.product' from v8 to v10
Tags: python;odoo-8;odoo
Question: in odoo store there is a module called ```product_pack```, it contains a file ```product.py```, this file contains the function bellow in ```version 8``` which is made to check product availability .

so, after trying to convert it to ```version 10``` I got an error exactly in line 6 and line 11. so my problem is exactly in converting ```res = super(product_product, self)._product_available(cr, uid, list(set(ids) - set(pack_product_ids)),field_names, arg, context)``` 

it raises: 

```
  pobjs = [adapt(o) for o in self._seq]
      ProgrammingError: can't adapt type 'product.product'
```


version 8

```def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None):

    pack_product_ids = self.search(cr, uid, [('pack', '=', True),
    ('id', 'in', ids),])
    res = super(product_product, self)._product_available(
        cr, uid, list(set(ids) - set(pack_product_ids)),
        field_names, arg, context)
    for product in self.browse(cr, uid, pack_product_ids, context=context):
        pack_qty_available = []
        pack_virtual_available = []
        for subproduct in product.pack_line_ids:
            subproduct_stock = self._product_available(cr, uid, [subproduct.product_id.id], field_names, arg,
                context)[subproduct.product_id.id]
            sub_qty = subproduct.quantity
            if sub_qty:
                pack_qty_available.append(math.floor(
                    subproduct_stock['qty_available'] / sub_qty))
                pack_virtual_available.append(math.floor(
                    subproduct_stock['virtual_available'] / sub_qty))
        res[product.id] = {
            'qty_available': (
                pack_qty_available and min(pack_qty_available) or False),
            'incoming_qty': 0,
            'outgoing_qty': 0,
            'virtual_available': (
                pack_virtual_available and
                max(min(pack_virtual_available), 0) or False),
        }
    return res
```
version 10 

```def _product_available(self, field_names=None, arg=False):

        pack_product_ids = self.search([('pack', '=', True)])
        ###res = super(product_product, self)._product_available(field_names, arg)
        for product in self.browse(pack_product_ids):
            pack_qty_available = []
            pack_virtual_available = []
        for subproduct in product.pack_line_ids:
            subproduct_stock = self._product_available([subproduct.product_id.id], field_names, arg)[subproduct.product_id.id]
            sub_qty = subproduct.quantity
            if sub_qty:
                pack_qty_available.append(math.floor(subproduct_stock['qty_available'] / sub_qty))
                pack_virtual_available.append(math.floor(subproduct_stock['virtual_available'] / sub_qty))
        res[product.id] = {
            'qty_available': (pack_qty_available and min(pack_qty_available) or False),
            'incoming_qty': 0,
            'outgoing_qty': 0,
            'virtual_available': (pack_virtual_available and max(min(pack_virtual_available), 0) or False),
        }
    return res
```


Thanks in advance

Comment: Hi,  the function that chack the availablity qty already exist in odoo10, serach in `stock/models/product.py` the function `_search_qty_available`

Comment: Make you sure the model uses is `product.produt` not `product.template`

Comment: thank you, but what they did here is new module named product_pack , and they override the function _product_available

Comment: it did work perfectly in v8, the problem here is the conversion of the method into v10 exactly in: res super(.......) and subproduct_stock = self._product_available(...)


Here is another answer: it did work using this one;

```@api.multi
def _product_available(self, field_names=None, arg=False):
    pack_products = self.filtered(lambda p: p.pack == True)
    res = super(product_product, self - pack_products)._product_available(field_names, arg)

    for product in pack_products:
        pack_qty_available = []
        pack_virtual_available = []
        for pack_line in product.pack_line_ids:
            subproduct_stock = pack_line.product_id._product_available(field_names, arg)[pack_line.product_id.id]
            sub_qty = pack_line.quantity
            if sub_qty:
                pack_qty_available.append(math.floor(
                    subproduct_stock['qty_available'] / sub_qty))
                pack_virtual_available.append(math.floor(
                    subproduct_stock['virtual_available'] / sub_qty))
        # TODO calcular correctamente pack virtual available para negativos
        res[product.id] = {
            'qty_available': (
                pack_qty_available and min(pack_qty_available) or False),
            'incoming_qty': 0,
            'outgoing_qty': 0,
            'virtual_available': (
                pack_virtual_available and min(pack_virtual_available) or False),
        }
    return res
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2018:00:01/24/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><odoo-8><odoo>', 'Title': "can't adapt type 'product.product' from v8 to v10", 'ViewCount': 200, 'id': 48420091, 'user_AboutMe': None, 'user_AccountId': 4524653.0, 'user_DisplayName': 'user3676872', 'user_Reputation': 203.0, 'user_Views': 57.0, 'user_id': 3676872.0}}