Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
764 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit
Nejlepší odpověď

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
Zrušit
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

Related Posts Odpovědi Zobrazení Aktivita
2
čvc 19
16043
4
čvc 25
445
1
kvě 25
754
0
lis 24
1415
0
bře 24
1393