'Get the remaining quantities per product on an operation with a package. This function returns a dictionary'

def _get_remaining_prod_quantities(self):

    if ((not self.package_id) or self.product_id):
        return {self.product_id: self.remaining_qty}
    res = self.package_id._get_all_products_quantities()
    for record in self.linked_move_operation_ids:
        if (record.move_id.product_id.id not in res):
            res[record.move_id.product_id] = 0
        res[record.move_id.product_id] -= record.qty
    return res
