This question has been flagged
1 Reply
5179 Views

I have created a dynamic field through field_view_get function . The problem is that when I try to store data to this field . It does not get stored. The field is not showing anything . I am confused because I think I will have to make an entry for this field in my database.

1) How can this be done ?

2) Second thing is how can we set a button to fields_view_get function ? If I want to create dynamic fields through a button click then will it be possible through fields_view_get or not?

Avatar
Discard

I have the same issue ,please give me the solution if you get it ?

i have also same issue, i want click on button create dynamic fields?

I found the solution by create the field by using self._columns['%s'%field_name] = fields.float('%s'%field_view_name,readonly=True) if not analytic_account_child_ids: result['fields'].update({ field_name : {'type':'float','readonly':True}, })

Best Answer

fields_view_get() is used to modified the displaying of a view. If you add a dynamic field on this method, you must also add this field in the fields_get() method.

But, if you need to save the value of this dynamic field, you should create a new fields on your object to save its value on the DB. Else, you need to develop a method to save the value in your proper way (in a file, in memory or anything else).

Avatar
Discard

i create my dynamic fileld and view , i just want to store that fields in database , please tell me how to add that fields in the fields_get() method?

In this case, you have to create a new Odoo module with an object that inherits of a base Odoo object and define a new columns for this object. After that, you have to modify the XML view of the object. fields_view_get() and fields_get() will not have to be overrided if you use the Odoo inheritance.