Odoo Help

2
10 Answers
2
Avatar

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
13045
| 7 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

ERP Harbor Consulting Services

Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
Sudhir Arya (ERP Harbor Consulting Services)
5/3/18, 1:45 AM

Hi Anil,

You can call search method using XML-RPC:

rpc_obj.execute(db_name, uid, pwd, 'ir.model.data', 'search', [('model', '=', 'res.partner'), ('name', '=', ext_id)])

Or you can create your own method in custom module and can call it using XML-RPC.

Hope this will help you.

Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
5 Comments
Anil R. Kesariya (AKE)
5/3/18, 2:05 AM

Thanks sudhir, found solution to get data of csv Id, any idea how to fetch database ID of imported record through xml ID?

Sudhir Arya (ERP Harbor Consulting Services)
5/3/18, 2:14 AM

Do you want DB ID using XML-RPC?

Anil R. Kesariya (AKE)
5/3/18, 2:41 AM

Yes. and I have the XML ID of that record as reference.

Sudhir Arya (ERP Harbor Consulting Services)
5/3/18, 3:10 AM

You can use same code I posted in my answer. When you record of ir.model.data object, get the value of "res_id" field.

Anil R. Kesariya (AKE)
5/3/18, 3:54 AM

Solved sudhir, thanks for your concerned and answer. :)

1
David Peralta
5/2/18, 11:48 AM

Hello

I hope I serve you here I have an example

Example 01:

self.env['ir.model.data'].search_read([('model', '=', 'res.partner'), ('name', '=', 'external_id_csv')], ['res_id'])

return tuple

# [{'res_id': id_database, 'id': id_record_model}]

example 02:

self.env['ir.model.data'].xmlid_to_res_id('your_module.external_id_csv')

1 Comment
Anil R. Kesariya (AKE)
5/3/18, 12:38 AM

self.env is accessible outside odoo.

0
Florent
11/22/18, 8:56 AM

There's a simpler solution involving ERPpeek :


----
# Let's say your Odoo module is 'test_module'
# and your csv contains external_ids 'test_001' 'test_002' for "res.partner" records

partner_001 = model("res.partner").get('test_module.test_001')
partner_002 = model("res.partner").get('test_module.test_002')

print(partner_001.id)
print(partner_002.id)


----
0
Avatar

Anil R. Kesariya (AKE)

--Anil R. Kesariya (AKE)--
6204
| 7 6 8
Rajkot, India
--Anil R. Kesariya (AKE)--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.


Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66


Anil R. Kesariya (AKE)
5/3/18, 2:03 AM

Hi All,

I have found the solution using ERPPeek lib. which using xmlrpc lib itself.

1. Here is the example, by using I found out Database ID of csv ID.

import erppeek
client = erppeek.Client('http://localhost:8888', 'database_name', 'username', 'pass')
model_data = client.model('ir.model.data')
source_data = model_data.search_read([('model','=','model_name'), ('name','=',external_csv_id)], ['res_id'])

The source data returns database ID as res_id.

This works perfectly if data loaded through csv file.

2. Here is the method Which I have tried to search database ID of record which have been imported  using XML IDs.

import erppeek
client = erppeek.Client('http://localhost:8888', 'database_name', 'username', 'pass')
 model_data = client.model('ir.model.data')
result = model_data.xmlid_lookup("%s.%s" % ('module_name', xml_id))
It returns the list of 3 items.
1 values is backend external ID
2. Model Name
3. Database ID.
o/p E.g. : [2172, 'res.groups', 3]

This is How, I found solution to get the database ID of the records with reference of XML ID.

works like a charm.

Regards,

Anil.


Ask a Question
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now