diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2022-11-15 17:35:23 +0700 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2022-11-15 17:35:23 +0700 |
| commit | f6671dd4595af3c1075b27925f10c457854cecf8 (patch) | |
| tree | fadac999707657fc3ce1b0e359e5acc69d497308 /indoteknik_api/models/product_product.py | |
| parent | 2861ba3cd7844079ce85ad31aa1470e95de7f71d (diff) | |
Fitur crud cart dan wishlist
Update struktur response product
Diffstat (limited to 'indoteknik_api/models/product_product.py')
| -rw-r--r-- | indoteknik_api/models/product_product.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py new file mode 100644 index 00000000..a1f22068 --- /dev/null +++ b/indoteknik_api/models/product_product.py @@ -0,0 +1,19 @@ +from odoo import models + + +class ProductTemplate(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) + data = { + 'id': product_product.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], + } + return data
\ No newline at end of file |
