Untitled

 avatar
unknown
python
4 years ago
666 B
8
Indexable
#This is the controllers.py file

from odoo import http
import logging
import json

logger = logging.getLogger(__name__)


class Os21Pharmacy(http.Controller):
    #Change the route to whatever you want
    @http.route('/ghazala/', auth='public')
    def index(self, **kw):
        #Change the model name in the following line to match your model name
        medicines = http.request.env['os21.pharmacy.medicine'].search([])
        dic = []
        #This is a loop for the array, make sure you have price defined in the model
        for medicine in medicines:
            dic.append({'name': medicine.name, 'price': medicine.price})
        return json.dumps(dic)
Editor is loading...