Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
10904 Vizualizări

i'am trying to integare odoo with  imdb.com which have it's own APIs on omdbapi.com 

i  need to fictch movies as products on odoo then make apurchase orders on it the site says\for searching i should use this api

\\\http://www.omdbapi.com/?apikey="i must but my key here"&t="the movie Name i want to search"

i'am tried to do it by this way

class Api(http.Controller):
@http.route('/api', auth='public', methods=["get"])
def index(self, **kw):
    url = 'http://www.omdbapi.com/?apikey=15439843&t=hello'
    r = requests.get(url)
    return r.text

it return a json with data of the movie hello but here it's a static parameter how can i make it dynamic and get the movie name from field or data input then i need to get the json parameters on method create of product.tempalte

add_product = http.request.env['product.template'].sudo().create({
         'name': "movie name form json"
         })
return add_product

any help well be very appreciated

Imagine profil
Abandonează
Cel mai bun răspuns
there is no need to create controller. just override create method of your model like

def create(self, vals):
name = vals.get('name')
if name:
url = 'http://www.omdbapi.com/?apikey=15439843&t=%s' % name
response = requests.get(url)
movies = response.json()
# formate movi list
self.env['product.template'].sudo().create({
'director': movies.get('Director')
})
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
iun. 21
2363
0
mar. 21
2432
4
feb. 17
21696
1
aug. 24
4564
1
sept. 23
2423