Skip to Content
Menu
This question has been flagged
719 Views
@http.route('/products', type='json', auth='user')
def getallproduct(self):
products_rec = request.env['product.template'].search([])
products = []
for rec in products_rec:
vals = {
#'Reference Number': rec.default_code,
#'Product Name': rec.name,
#'quantity': rec.qty_available,
'location': rec.warehouse_id.name,
#'unit': rec.uom_id.name
}
products.append(vals)
print('Product List --->', products)
print('Total products is', len(products))
data = {'status': 200, 'response': products, 'message': 'Done All Products Returned'}
return data

when i test this api on POSTMAN,it displays, "location": false, but there are warehouse in my database. can you help me please??
Avatar
Discard