Odoo Help

Welcome!

This community 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.

0

How to get model_id in fiels_view_get function?

By
Adrian
on 7/23/13, 7:33 AM 1,159 views

I have a custom module, and i want to modify a field just before it opens(basically update the model's field, from another model) and i need to use the fields_view_get function... but i don't know how to get the id o f the opened model...the context doesnt have it, and what the super() gives back (res) doesnt contains those data...

How can i get the current active model id?

1

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 10/11/13, 10:38 AM

Hi, what is the print result of this code in first part of method fields_view_get :

cr.execute("""SELECT id FROM ir_model 
                          WHERE model = %s""", (str(self._name),))            
info = cr.dictfetchall()  
if info:
    model_id = info[0]['id'] 
    print str(model_id)

Bye

0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 10/11/13, 8:21 AM

You can't. I've the some problem and I searched a solution with a lot of ways but I think it's impossibile because when fields_view_get trigs you haven't reference to original record.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 7/23/13, 7:33 AM
Seen: 1159 times
Last updated: 3/16/15, 8:10 AM