Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
802 Vistas

Hi, i try make phone lookup addon which fetches name for the number from odoo database and show it on mobile phone

The problem what I have now is how to select database with custom url (if multiple database on same domain)?


I have ULR like below but db parameter doesn't work...


https://odoo.domain.com/lc_phonenumber_lookup/Search?phoneNumber=1234567890&db=mydb2


What I need to add to controller to make it work?

Avatar
Descartar
Mejor respuesta

Hello timo,

I believe there is no need to add such URL and thing for it if you want to make the name search via phone number you can do it so via the namesearch method too.

Check the name search method which will help you do the same as it is currently working in the backend and fronted so I will basically wirork in the mobile phone too, 

if it don't so then I believe the db thing doesn't need to be added as the odoo doesn't cater the db like this so remove the db from the URL it should work or it still shows the 404 then the error is of handling  the controller provide me the code so I can help with it further 

Thanks!

Avatar
Descartar
Autor Mejor respuesta

Thanks for quick reply.

I tried with your code but still get 404 error?

I also forget mention Odoo version but it is 17 enterprise.

Avatar
Descartar
Mejor respuesta

To make ?db=mydb2 work in your Odoo controller:

  1. Set this in odoo.conf:

    ini

    CopyEdit

    dbfilter = .*

  2. Update your controller:

    python

    CopyEdit

    from odoo import http from odoo.http import request class PhoneLookup(http.Controller): @http.route('/lc_phonenumber_lookup/Search', type='http', auth='public', csrf=False) def search(self, phoneNumber=None, db=None, **kw): if db: request.session.db = db partner = request.env['res.partner'].sudo().search([('phone', '=', phoneNumber)], limit=1) return partner.name if partner else "Not found"

That’s it! Now ?db=mydb2 will work.

Avatar
Descartar
Autor

Thanks for quick reply.

I tried with your code but still get 404 error?

I also forget mention Odoo version but it is 17 enterprise

Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 19
16074
4
jul 25
482
1
may 25
783
0
nov 24
1426
0
mar 24
1405