from odoo import models class ProductProduct(models.Model): _inherit = 'product.product' def api_single_response(self, product_product): product_pricelist_default_discount_id = self.env['ir.config_parameter'].get_param('product.pricelist.default_discount_id') product_pricelist_default_discount_id = int(product_pricelist_default_discount_id) product_template = product_product.product_tmpl_id data = { 'id': product_product.id, 'parent': { 'id': product_template.id, 'name': product_template.name, 'image': self.env['ir.attachment'].api_image('product.template', 'image_256', product_template.id), }, 'code': product_product.default_code or '', 'name': product_product.display_name, 'price': self.env['product.pricelist'].compute_price(product_pricelist_default_discount_id, product_product.id), 'stock': product_product.qty_stock_vendor, 'weight': product_product.weight, 'attributes': [x.name for x in product_product.product_template_attribute_value_ids], 'manufacture' : self.api_manufacture(product_product) } return data def api_manufacture(self, product_template): if product_template.x_manufacture: manufacture = product_template.x_manufacture return { 'id': manufacture.id, 'name': manufacture.x_name, 'image_promotion_1': self.env['ir.attachment'].api_image('x_manufactures', 'image_promotion_1', manufacture.id), 'image_promotion_2': self.env['ir.attachment'].api_image('x_manufactures', 'image_promotion_2', manufacture.id), } return {}