Skip to Content
Menu
This question has been flagged
1 Reply
3288 Views

Hi,

I need to add a default search with a string. Like in the interface I can do this, filter reference contains POS. so I will get the journal entry with the reference POS.

I tried giving context as <field name="context">{ 'search_default_ref':'POS'}</field>

but no luck. How can I do that ?

Help is appreciated.

Thanks.


Avatar
Discard
Best Answer

Hi,

‘search_default_ref: ‘POS’ will not work here.

For filter default by POS you need to add new filter into the search view as follows :

<record id="filter_by_ref" model="ir.ui.view">
<field name="name">Journal Items</field>
<field name="model">account.move.line</field>
<field name="inherit_id" ref="account.view_account_move_line_filter"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<filter string="POS Reference" name="pos_reference" domain="[('move_id.ref','ilike','POS%')]"/>
</xpath>
</field>
</record>

And now in the action you can pass the context as ‘search_default_pos_reference':1

Avatar
Discard
Author

It worked

Thanks a lot!