Odoo Help

0

How to apply attrs attribute other field depend from many2many field. ?

By
Ankit H Gandhi(AHG)
on 2/26/15, 6:54 AM 1,451 views

Hello Friends,

I want to apply attrs on other fields select from many2many field.

in .py file which have

classs student_info(osv.Model):

_name = 'student.info'

_columns = {

'nick_name_ids': fields.many2many('nick.name', 'student_nick_name_rel', 'student_id', 'nick_id', string='Nick Name'),

'nick_name_1': fields.char('Nick Name 1'),

'nick_name_2':fields.char('Nick Name 2'),

'nick_name_2':fields.char('Nick Name 3').

}

now in .xml file

<record id="view_student_info_form" model="ir.ui.view">
            <field name="name">view.student.info.form</field>
            <field name="model">student.info</field>
            <field name="arch" type="xml">
                <form string="Student Info Form View">
                    <sheet>
                        <group>
                            <group>
                                <field name="nick_name_ids"/>
                                <field name="nick_name_1" attrs="{'invisible':[('nick_name_ids', '=','?????']}"/>
                                <field name="nick_name_2"  attrs="{'invisible':[('nick_name_ids', '=','?????']}"/>
                                <field name="nick_name_3" attrs="{'invisible':[('nick_name_ids', '=','?????']}"/>
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

what i should write instead of ?????

Thank in advance,

1

Serpent Consulting Services Pvt. Ltd.

--Serpent Consulting Services Pvt. Ltd.--
4436
| 6 6 8
Gandhinagar, India
--Serpent Consulting Services Pvt. Ltd.--

Serpent Consulting Services Pvt. Ltd. Your Odoo/OpenERP Solution, just an email away!

Serpent Consulting Services Pvt. Ltd.
On 2/26/15, 7:48 AM

Dear Ankit,

You must know more here.

The attrs works on client side only, is evaluated on client parser only.

You must try these ways:

A. specify ('nick_name_ids', 'in', LIST OF NAMES)] Or try IDs(not recommended though).

B. Have an invisible field of type char which keeps the values of nick_name_ids. You may run your attrs easily then. You may even do smarter things based on the onchange of M2M field.

Thanks.

 

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: 2/26/15, 6:54 AM
Seen: 1451 times
Last updated: 3/16/15, 8:10 AM