diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-01-23 14:44:12 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-01-23 14:44:12 +0700 |
| commit | 8af5ee591aabc2d5d946c0eece93a5caab989975 (patch) | |
| tree | a81740fff5f248bd4dd6b190f8650cdfa8849b47 /indoteknik_api/models/product_product.py | |
| parent | 4bc68435bc20d7da0f38bd2370057481cb995584 (diff) | |
Fix get api image logic
Diffstat (limited to 'indoteknik_api/models/product_product.py')
| -rw-r--r-- | indoteknik_api/models/product_product.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 6b02d91e..2e84b9f4 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -5,7 +5,6 @@ class ProductProduct(models.Model): _inherit = 'product.product' def api_single_response(self, product_product): - base_url = self.env['ir.config_parameter'].get_param('web.base.url') 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 @@ -14,7 +13,7 @@ class ProductProduct(models.Model): 'parent': { 'id': product_template.id, 'name': product_template.name, - 'image': base_url + 'api/image/product.template/image_256/' + str(product_template.id) if product_template.image_256 else '', + '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, @@ -27,13 +26,12 @@ class ProductProduct(models.Model): return data def api_manufacture(self, product_template): - base_url = self.env['ir.config_parameter'].get_param('web.base.url') if product_template.x_manufacture: manufacture = product_template.x_manufacture return { 'id': manufacture.id, 'name': manufacture.x_name, - 'image_promotion_1': base_url + 'api/image/x_manufactures/image_promotion_1/' + str(manufacture.id) if manufacture.image_promotion_1 else '', - 'image_promotion_2': base_url + 'api/image/x_manufactures/image_promotion_2/' + str(manufacture.id) if manufacture.image_promotion_2 else '', + '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 {}
\ No newline at end of file |
