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

Hi everyone,i modify the module rh and now i want to add a field many2one in an other module from employee who have a job professor but i have this error:

ValueError: Invalid field u'job_id.name' in leaf "<osv.extendedleaf: (u'job_id.name',="" u'=", u" prof')="" on="" hr_job="" (ctx:="" )&gt;"<="" p="">

code of the file.py

enter code hereclass school_matiere(osv.osv):
''' matiere '''
_description ='Information sur les matieres'
_name = 'school.matiere'

_columns = {
    'name': fields.char('libelle matiere', size=64, required=True, select=1),
    'code': fields.char('Code matiere', size=20, required=True, select=1),
    'coef_mat': fields.integer('coefficient matiere'),
    'teacher_id': fields.many2one('hr.employee', 'Professeur responsable',required=True),
}

school_matiere()

code of file.xml

enter code here<record model="ir.ui.view" id="view_school_matiere_form">
        <field name="name">school.matiere.form</field>
        <field name="model">school.matiere</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Matiere" version="7.0">
            <sheet>
                <group col="6" colspan="4">
                <field name="teacher_id" domain="[('job_id.name','=','prof')]"/>
                    <field name="name" />
                    <field name="code" />
                    <field name="coef_mat" />
                </group>
                 </sheet>
            </form>
        </field>
    </record>
아바타
취소
베스트 답변

Hi

your Domain expr... is wrong as .. you are searching in hr.jobs, there is no field name "job_id" that's why you are getting this error

try this ...

<field name="teacher_id" domain="[('job_id.name','=','prof')]"/>

the above example only for those records which contents value 'prof' in name field means those records will be displayed where name='prof' you can use according to you....

아바타
취소
작성자

Hi it worked at the beginning but now i find the value "prof" and not the employee who i want to select...any idea please

in the module hr.job which records contents value 'prof' in the name field , those records will be display ... can you tell what actually you want , what kind of employee you want in search

작성자

I want to display employees who have the job 'teacher (in the HR module) in another module that I developed via the field many2one (the code above)

where you want to display , this is an example of , when you select teacher_id in employee

here in school.matiere module you are not display employee you are display hr.job means job position .. where name='prof'

작성자

exactly but teacher_id is in another class

ok now , do one think , 'teacher_id': fields.many2one('hr.employee', 'Professeur responsable',required=True), not hr.job ... and then in domain add your previous think means ... ....... &lt;field name="teacher_id" domain="[('job_id.name','=','prof')]"/&gt; ... then it will run perfectly as you want

i updated your code in your Q you can copy this code now it will run perfectaly

작성자

i have this error: ValueError: Invalid field u'job_id.name' in leaf "<osv.ExtendedLeaf: (u'job_id.name', u'=', u'prof') on hr_job (ctx: )>"

작성자

yes thank you it work's now...I had to create a new database and restart service

작성자 베스트 답변

it work's now i just modify hr.employee by hr.job in the field

'teacher_id': fields.many2one('**hr.job**', 'Professeur responsable',required=True),
아바타
취소
관련 게시물 답글 화면 활동
4
3월 24
3637
1
10월 23
5536
1
6월 22
6828
4
6월 21
16079
2
8월 17
12792