summaryrefslogtreecommitdiff
path: root/indoteknik_api/models/product_product.py
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-04-08 13:35:11 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-04-08 13:35:11 +0700
commit307682aaa5dcbdeab60e6b3a49e3dce50e72218b (patch)
tree173e7363012cec62c2609e332c5941cabea788ca /indoteknik_api/models/product_product.py
parent7b6cdcaae39893e7ed682b4d5864f4365c92f37a (diff)
fixing api product
Diffstat (limited to 'indoteknik_api/models/product_product.py')
-rw-r--r--indoteknik_api/models/product_product.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py
index f83ede27..c867eaa0 100644
--- a/indoteknik_api/models/product_product.py
+++ b/indoteknik_api/models/product_product.py
@@ -25,6 +25,31 @@ class ProductProduct(models.Model):
'manufacture' : self.api_manufacture(product_product)
}
return data
+
+ def v2_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': {
+ 'price': product_product._get_website_price_exclude_tax(),
+ 'discount_percentage': product_product._get_website_disc(0),
+ 'price_discount': product_product._get_website_price_after_disc_and_tax()
+ },
+ '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: