Odoo Help

0

access to many2one in the view

By
josemi
on 4/21/16, 4:26 AM 465 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

3
Jignesh Mehta
On 4/21/16, 4:55 AM

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,

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'}

josemi
on 4/21/16, 6:32 AM

Sorry {'default_type':'notification'}

josemi
on 4/21/16, 6:34 AM
1
Prakash Sharma
On 4/21/16, 4:54 AM

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 

 

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'}

josemi
on 4/21/16, 6:32 AM
0
josemi
On 4/21/16, 5:15 AM

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>

look my updated ans.

Jignesh Mehta
on 4/21/16, 5:52 AM

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

webkul, Prakash Sharma
on 4/21/16, 5:53 AM

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

webkul, Prakash Sharma
on 4/21/16, 5:55 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 4/21/16, 4:26 AM
Seen: 465 times
Last updated: 4/21/16, 7:07 AM