Hi Community.
I have made a new module, where I can get a json from products.
I made it like this:
***python file***
#GET PRODUCTS
@http.route(['/academy/products'], type='json', auth="public", website=True)
def return_map(self, productIds, **post):
cr, uid, context = request.cr, request.uid, request.context
mainModel = request.registry.get('product.template')
resultModel = mainModel.search_read(cr, SUPERUSER_ID, [("id", "=", productIds)],
['quantityformula', 'incoming_qty', 'standard_price', 'display_name',
'pricelist_id', 'outgoing_qty', 'website_style_ids', 'rental',
'website_sequence', 'name', 'packaging_ids', 'pos_categ_id',
'website_message_ids', 'accessory_product_ids', 'message_follower_ids',
'sequence', 'attribute_line_ids', 'description_purchase',
'is_feture_product', 'index', 'virtual_available', 'income_pdt',
'gio_preselected', 'price', 'sales_count', 'active', 'loc_row',
'product_variant_count', 'seller_delay', 'loc_case',
'property_stock_account_output', 'track_all', 'qty_available_text',
'lst_price', 'message_unread', 'warranty', 'property_stock_procurement',
'uos_id', 'list_price', 'color', 'public_categ_ids',
'is_recommended_product', 'mes_type', 'qty_available', 'expense_pdt',
'uos_coeff', 'create_uid', 'sale_ok', 'message_is_follower',
'__last_update', 'product_manager', 'message_last_post', 'type',
'track_incoming', 'property_stock_production', 'supplier_taxes_id',
'volume', 'website_meta_description', 'property_stock_inventory',
'seller_qty', 'valuation', 'sale_delay', 'alternative_product_ids',
'product_variant_ids', 'description_sale', 'available_in_pos',
'gio_imagelayer', 'website_meta_keywords', 'id', 'website_meta_title',
'uom_po_id', 'description', 'is_product_variant', 'templateUrl',
'website_description', 'taxes_id', 'gio_hasimage'], context=context)
return {"status": "success", "data": resultModel}
*****JS File*****
var requestUrl = '/academy/products';
openerp.jsonRpc(requestUrl, 'call', {productIds: 41},{})
.then(function (data) {
alert(data['x']);
});
I see the json when I run the website /academy/products with FIDDLER. Is there a better way to see the json output on the website itself?
and
How can I make a POST ?
Thank you very much.