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

Hello,

On Odoo v13 :


I added a domain on a many2one field like below, to have only sign request signed :

field name="s_sign_request_id" domain="[['state', '=', 'signed']]"


It works well but if i choose the line "Search more...", in the tree view, there is only signed requests and i could not see others (sent or cancelled)

So i added in my field a context to add a filter by default like this :

field name="s_sign_request_id" domain="[['state', '=', 'signed']]" context="{'search_default_signed': 1, 'state': 'signed'}"


I can see the filter (in the search field on the top right) but only signed requests are displayed even if i unchecked the "signed" filter!?


Is there a way to filter content of the many2one but not content of tree view (except with default filter) ?

Avatar
Discard
Best Answer

Hello Vincent DUBREIL,

Please Find Code in Comment.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard

Please find below code it may help you to resolve this issue,

<field name='field_name' domain="[('state', '=', 'signed')]" context="{'is_state_signed': True}"/>

@api.model
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None):
if self._context.get('is_state_signed'):
domain += [()]
return super(Employee, self).search_read(domain=domain, fields=fields, offset=offset, limit=limit, order=order)