This question has been flagged
3962 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

Avatar
Discard

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

Author

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

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