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 update column dictionary in openerp 7?

By
arsalan
on 4/11/14, 8:32 AM 1,369 views

I need to ask how can we update the columns dictionary in openerp7 . I have created dynamic field through button click. The field created is in the db . But to have it on my form , I must update it in the columns dictionary and I donot want it to manually add under _columns. Is there a way to connect a function to a button to update the columns with the newly created field. Without updating to _columns, its not working.

Thanks all

Hi Arsalan,

If you add columns for any module by button click from front end then, it'll keep those in database, which will be not permanent and upon database switch the changes will not reflect.

Hence if it is your custom module, then please add the fields in the _columns dictionary and if it is a base module then, you need to inherit it and add in _columns dictionary. For inheriting module you have to add _inherit = 'base.module.name' in your custom class.

Thanks

ASP
on 4/11/14, 12:03 PM

what I want here is the syntax for updating the field details to _column dict. Hello , I want to know the way to update column dict . Because every now and then I am getting a syntax error. I am using following method definition. Please guide me to fix the issue. def update_column(self,cr,uid,view_id,view_type='form'): fields={} fields.add(string='Names',type='char') _columns.update(fields) . pls guide me

arsalan
on 4/21/14, 6:20 AM

Hi Arsalan,

The _columns of any module comprises the corresponding DB fields, and if we need some more/new fields we need to simply add it to that manually and restart server to reflect the changes. Here we are writing to a file (.py) , hence the changes will be permanent, over databases just by upgrading the module. But if you try adding/updating that _columns by any method, the changes will be temporary, i.e., upon upgrading/switching DB or re-installing module these fields will be gone. So your function needs to write to the model file (.py) _columns dictionary. Cheers

ASP
on 4/22/14, 4:15 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

0 follower(s)

Stats

Asked: 4/11/14, 8:32 AM
Seen: 1369 times
Last updated: 3/16/15, 8:10 AM