跳至内容
菜单
此问题已终结
2 回复
21983 查看

In openerp 7 related date field in Search view group by not working

Code:-

  'date'  : fields.related('intake_id', 'date', type="function", relation="table2.object", string="Date"),

 <filter string="Date" icon="terp-partner" domain="[]" context="{'group_by':'date'}"/>

In the table1.object list view the code added. its shows errors date field not find in table2.object.

So applied the below code using dot notation with object name or many2one field.

<filter string="Date" icon="terp-partner" domain="[]" context="{'group_by':'table2_object.date'}"/>
or
<filter string="Date" icon="terp-partner" domain="[]" context="{'group_by':'intake_id.date'}"/>

But facing the same issues...

形象
丢弃
最佳答案

you can't filter and group_by if this field is not store in database.

  'date'  : fields.related('intake_id', 'date', type="function", relation="table2.object", string="Date", store=True),

Use store=True

形象
丢弃

How do you force the field to be updated when the related object changes? I've had problems if the value is stored, it doesnt always get updated?!

You can set a trigger for updating a field with 'store' attribute. The syntax is as follows (from the technical memento): >>> store = {'model': (_ref_fnct, fields, priority)}

But, in the last versions, many fields are not stored by default and you can group it.

编写者 最佳答案

Thanks for reply solved in localhost. But in the Production server i have more than 2000 records recently added the related fields to store=True and restarted server. After that shows the below error.

line 2787, in _update_store File "C:\Program Files (x86)\OpenERP 7.0-20130308-002138\Server\server.\openerp\osv\fields.py", line 1131, in get File "C:\Program Files (x86)\OpenERP 7.0-20130308-002138\Server\server.\openerp\osv\fields.py", line 1208, in _fnct_read File "C:\Program Files (x86)\OpenERP 7.0-20130308-002138\Server\server.\openerp\osv\fields.py", line 1208, in <genexpr> KeyError: 4

In existing database it is possible to add relation field to store true?....

形象
丢弃

you should upgrade module after change view, fields.

编写者

yes i updated the module show same error. Using two related fields one for data type date and another many2one field.

or write script to update this fields.

编写者

it means to update the field using sql query. Thanks for reply Issue fixed already updated field data using update query