hi !
I have in my new module a functional field, whene i put it in my tree view i can't open my view.
here the action code :
<record id="my_module_normal_action" model="ir.actions.act_window">
<field name="name">My module</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mymodule</field>
<field name="domain">[('my_field','=',True)]</field>
<field name="view_type">form</field>
<field name="view_id" ref="my_module_tree_view"/>
<field name="search_view_id" ref="my_module_search_form_view"/>
</record>
my code xml :
<record id="my_module_tree_view" model="ir.ui.view">
<field name="name">my.module.tree</field>
<field name="model">mymodule</field>
<field name="type">tree</field>
<field eval="7" name="priority"/>
<field name="arch" type="xml">
<tree string="my module">
<field name="my_string"/>
<field name="my_field"/>
</tree>
</field>
</record>
in my python code :
'my_field': fields.function(_get_concatenate_values, method=True, string='Reference', type='char'),
this is the function's code :
def _get_concatenate_values(self, cr, uid, ids, field_name, arg, context=None):
records=self.browse(cr,uid,ids)
result={}
for r in records:
if(r.field1 and r.field2):
result[r.id]= str(r.field1.name)+'.'+ str(r.field2.name)
return result
"my_field"'s value is the concatenation of the two fields :field1 and field2
thanks for your reply.
What version of OpenERP are you using? Your field is called 'code' but you use 'my_string' and 'my_module' in the view?
I use V6.0.2 , my feild's name is 'my_field', 'my_sring' is an other field in my module. so I rectify the python code : 'my_field': fields.function(_get_concatenate_values, method=True, string='Reference', type='char'),