diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-12-14 13:56:12 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-12-14 13:56:12 +0700 |
| commit | a2dba2802a52a8cf6d81e863dbcd3b7cfb6ac43e (patch) | |
| tree | a360a459aa20cd82dd8912a33f03ad3cb58467a4 /indoteknik_api/models | |
| parent | 8d878a892f3eab49d23b161ba8916fbdb8bbb785 (diff) | |
API get product variant
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/product_product.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index a1f22068..4cff6b5c 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -5,10 +5,17 @@ class ProductTemplate(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 data = { 'id': product_product.id, + '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 '', + }, '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), |
