Odoo Help

Welcome!

This community 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.

0

access to many2one in the view

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

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


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

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

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

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

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

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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