Arsalan Sherwani
Arsalan Sherwani

Reputation: 560

How to create dynamic fields in openerp 7 module?

I am working on creating an openerp 7 module, I have been using eclipse IDE with Python for running the code. I want to give the feature of creating dynamic fields. I want to call a form in which the details(name,data type,size) of the field will be provided by user to create that new field. I have no such idea for dynamic field creation . plz help me.

Hopes for sugestion

Upvotes: 1

Views: 1412

Answers (1)

OmaL
OmaL

Reputation: 5044

You can use fields_view_get function in the osv for creating dynamic fields. Inherit the fields_view_get() function.

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False):
    result = super(<your_class_name>, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar)
    ###your modification in the view
    ###result['fields'] will give you the fields. modify it if needed
    ###result['arch'] will give you the xml architecture. modify it if needed
    return result

First check what is getting for your. Then build an idea on it and proceed. You can find an example in account module, account_invoice.py file

Upvotes: 1

Related Questions