from .. import controller from odoo import http from odoo.http import request class V2Product(controller.Controller): prefix = '/api/v2/' @http.route(prefix + 'product/', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def v2_get_product_by_id(self, **kw): id = kw.get('id') if not id: return self.response(code=400, description='id is required') data = [] id = [int(x) for x in id.split(',')] product_templates = request.env['product.template'].search([('id', 'in', id)]) if product_templates: data = [request.env['product.template'].v2_api_single_response(x, with_detail='DEFAULT') for x in product_templates] return self.response(data)