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.

1

including a field from an inherited module

By
oumaima
on 5/13/13, 8:21 AM 2,687 views

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

Sandeep

--Sandeep--
6083
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 5/13/13, 9:51 AM

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

oumaima
on 5/15/13, 8:16 AM

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

Sandeep
on 5/15/13, 8:35 AM

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)

oumaima
on 5/15/13, 8:39 AM

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

Sandeep
on 5/15/13, 8:43 AM

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

Sandeep
on 5/15/13, 8:45 AM

exactly but teacher_id is in another class

oumaima
on 5/15/13, 8:45 AM

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

Sandeep
on 5/15/13, 8:47 AM

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

Sandeep
on 5/15/13, 8:52 AM

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: )>"

oumaima
on 5/15/13, 8:54 AM

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

oumaima
on 5/15/13, 9:04 AM
0
oumaima
On 5/13/13, 8:42 AM

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),

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

0 follower(s)

Stats

Asked: 5/13/13, 8:21 AM
Seen: 2687 times
Last updated: 3/16/15, 8:10 AM