コンテンツへスキップ
メニュー
この質問にフラグが付けられました
3 返信
768 ビュー

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?

アバター
破棄
最善の回答

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!

アバター
破棄
著作者 最善の回答

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.

アバター
破棄
最善の回答

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.

アバター
破棄
著作者

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

関連投稿 返信 ビュー 活動
2
7月 19
16046
4
7月 25
446
1
5月 25
756
0
11月 24
1416
0
3月 24
1395