Skip to Content
Menu
This question has been flagged
3 Replies
4432 Views

I have a field many2one

state = fields.Many2one ("ags.traffic.operation.state")

state has the following fields (name = fields.Char, sequence = fields.Integer, type = fields.Selection)

if I write from sight <field name = "state" widget = "statusbar" clickable = "True" attrs = "{'invisible': [('state.type', '=', 'notification')]}" / >

does not work and gives the error "Error: Unknown field state.type domain [[" state.type "," = "," notification "]]"

I can accessed as fields (name, sequence or type) from the view ??

Thanks

Avatar
Discard
Best Answer

Hello Josemi,


Try this :-

<field name = "state" widget = "statusbar" clickable = "True" attrs = "{'invisible': {'state': [('type', '=', 'notification')]}}" / >


Second Solution :-

In py:-

state = fields.Many2one ("ags.traffic.operation.state")

type = fields.Selection(related='state.type', 'Type')

In Xml:-

<field name="state" attrs="{'invisible': [('type', '=', 'notification')]}" />

<field name="type" invisible="1"/>


Hope it works for you.

Thanks,

Avatar
Discard
Author

Thranks work, And to add as a default value an action in the context of? how would it be? in this way it does not work {'default_type':'notification'}

Author

Sorry {'default_type':'notification'}

Best Answer

Go through these steps:

  1.  Create a relate field  with ,Many2one:state

  2. Define this field in the view

  3. Now use in  attrs 

     

It will work 

 

Avatar
Discard
Author

Thanks And to add as a default value an action in the context of? how would it be? in this way it does not work {'default_type':'notification'}

Author Best Answer

Jignesh Mehta so it is always invisible

Prakash Sharma i dont't understand

And to add as a default value an action in the context of? how would it be?

in this way it does not work

<field name="context">{'default_type':'notification'}</field>

Avatar
Discard

look my updated ans.

you are using 'state.type' it will not work create a relate field (type) first , state.type can't be accessible

Jignesh had put the exact code "type = fields.Selection(related='state.type', 'Type')"