Odoo Help

2
2
Avatar

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
12459
| 6 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)
On 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

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

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

Do you want DB ID using XML-RPC?

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

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

Anil R. Kesariya (AKE)
on 5/3/18, 2:41 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.

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

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

Anil R. Kesariya (AKE)
on 5/3/18, 3:54 AM
1
David Peralta
On 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')

self.env is accessible outside odoo.

Anil R. Kesariya (AKE)
on 5/3/18, 12:38 AM
0
Avatar

Anil R. Kesariya (AKE)

--Anil R. Kesariya (AKE)--
6149
| 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)
On 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.


About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Odoo Training Center

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

Test it now

Question tools

1 follower(s)

Stats

Asked: 5/2/18, 9:31 AM
Seen: 1092 times
Last updated: 8/21/18, 11:48 PM