콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
8941 화면

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,

아바타
취소
베스트 답변

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.

 

아바타
취소
관련 게시물 답글 화면 활동
0
4월 21
5515
3
7월 19
6815
1
8월 23
3350
0
11월 21
2408
4
10월 21
80132