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

Can V7 and V8 code coexist in the same .py file?

By
Yakito
on 3/1/15, 11:24 AM 555 views

Hi, 

Today I wanted to translate parts of my code from v7 to v8. For that I changed the call (osv.osv) to (models.Model) and also changed the way I created my fields removing _column. I did all that in order to have a compute  field instead of a fields.function

But I found out that when I try to add 

from openerp import models, fields, api

in the same file where I have

from openerp.osv import fields, osv

It messes everything up. For example under openerp fields Char fields exist, but on openerp.osv fields its only char (lowercase C)

I was also getting 'field not found errors' .

So the question would be, is it possible to have v7 and v8 code in the same .py?

If it is not, should I create a new .py file for my v8 code and call it in my __init__ file?

Thanks for any clarification

1
Jordan Vrtanoski
On 3/2/15, 12:11 AM

You need to have separate namespace for the overlapping modules that you are importing as in this example:

from openerp.osv import fields as fields7, osv

Oh perfect! I didn't know about the 'as' . Thank you very much!

Yakito
on 3/2/15, 10:43 AM

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

2 follower(s)

Stats

Asked: 3/1/15, 11:24 AM
Seen: 555 times
Last updated: 3/16/15, 8:10 AM