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

Developing new module, am I using API v7 in this block of code?

By
E.M.
on 2/5/16, 7:12 PM 403 views

I suspect that I am using old API in this code block:

Model = request.registry['stock.picking']
cr, uid, context = request.cr, request.uid, request.context
fields = [ 'id' ]
current_stock_picking = Model.read(cr, uid, [int(id)], fields, context)[0]['id']


Which would be the equivalent in API 8?

The code is included in a controller, should I use any decorator for using API 8?


0

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/5/16, 7:21 PM

Just change it to:

env['stock.picking'].read([int(id)], fields)[0]['id']

The values of the fields list should be other than 'id', because the field id it will always returned in the dict of result for a given id and also you have it in the var id

I tried and it does not work. It returns an empty list.

E.M.
on 2/6/16, 4:28 AM
0
E.M.
On 2/6/16, 3:59 AM

Thanks Axel,

I do 

env = Env(cr, uid, context)

to get env.

Any possibility to use directly env? (I am using it inside a controller)

solved then?

Axel Mendoza
on 2/26/16, 9:44 PM

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

1 follower(s)

Stats

Asked: 2/5/16, 7:12 PM
Seen: 403 times
Last updated: 2/6/16, 4:27 AM