Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

How to fill a many2one field in openerp

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
many2oneopenerp7
3 Răspunsuri
7804 Vizualizări
Imagine profil
Rihene

Hello everybody:

Please, i have an employee_id which is a many2one field.

And a function to fill in the any2one but my function allows me to get the employee_id in hr_contract model.

I got every thing but when i click i have got an error:

Python:

obj3 = self.pool.get('hr.contract')

obj_ids3 = obj3.search(cr, uid, [('employee_id','=',key)])

res3 = obj3.read(cr, uid, obj_ids3, ['id', 'date_start','trial_date_start','employee_id'], context) 

for s in res3:

print s['date_start']

if s['trial_date_start'] == False:

s['date_start'] = s['date_start']

else:

s['date_start'] = s['trial_date_start']

key = s['employee_id']

print key[1]

inputs = {

'date_contract' : s['date_start'],

'matricule' : key[0],

'employee_id' : s['employee_id'],

'initial_leaves' : 0.0,

}

ret += [inputs]

And the field is:

'employee_id' : fields.many2one('hr.employee', string="Employee"),

The error:

2015-11-04 16:13:31,073 14952 ERROR openerp openerp.sql_db: bad query: insert into "seetek_leaves_line" (id,"year_id","employee_id","date_contract","initial_leaves","matricule",create_uid,create_date,write_uid,write_date) values (129,25,ARRAY[2, 'ABDELWAHED RIHENE'],'2015-08-29',0.0,2,1,(now() at time zone 'UTC'),1,(now() at time zone 'UTC'))

Traceback (most recent call last):

File "/opt/openerp/v7/server/openerp/sql_db.py", line 226, in execute

res = self._obj.execute(query, params)

DataError: invalid input syntax for integer: "ABDELWAHED RIHENE"

LIGNE 1 : ...ate,write_uid,write_date) values (129,25,ARRAY[2, 'ABDELWAHE...

^

Can any one help me please


2
Imagine profil
Abandonează
Imagine profil
Rihene
Autor Cel mai bun răspuns

Hi friends;

Here is the solution:

obj3 = self.pool.get('hr.contract')

obj_ids3 = obj3.search(cr, uid, [('employee_id','=',key)])

res3 = obj3.browse(cr, uid, obj_ids3, context=context)

for s in res3:

if s.trial_date_start == False:

date_start = s.date_start

else:

date_start = s.trial_date_start 

inputs = {

'date_contract' : date_start,

'matricule' : s.employee_id.matricule

'employee_id' : s.employee_id.id,

'initial_leaves' : 0.0,

}

ret.append(inputs)

return ret

Regards.

1
Imagine profil
Abandonează
Imagine profil
Akhil P Sivan
Cel mai bun răspuns

You may try like this:


obj3 = self.pool.get('hr.contract')
obj_ids3 = obj3.search(cr, uid, [('employee_id','=',key)])
res3 = obj3.browse(cr, uid, obj_ids3, context=context)
for s in res3:
if s.trial_date_start == False:
date_start = s.date_start
else:
date_start = s.trial_date_start
key = s.employee_id
inputs = {

'date_contract' : date_start,

'matricule' : key[0],

'employee_id' : s.employee_id.id,

'initial_leaves' : 0.0,

}
ret.append(inputs)

return ret


1
Imagine profil
Abandonează
Rihene
Autor

Thanks a lot akhil for your help but there is a little mistake :/ i have corrected it below :)

Akhil P Sivan

That was not a mistake Drees, because I didn't what you meant by matricule. The problem in your question was instead of employee_id which is supposed to be an integer, you were passing an array. So dealing with a browse method is better than with read method to get it correctly. I just randomly put matricule, as you can give any value which you may need. But I forgot to mention it, that was my mistake, I agree :)

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
many2one show all the fields
many2one openerp7
Imagine profil
Imagine profil
Imagine profil
2
feb. 25
9287
Filter only partner as is_company in many2one field on openerp 7 ? Rezolvat
many2one openerp7
Imagine profil
Imagine profil
2
iun. 15
8656
Autofill many2one field with the "Owner" id
modules many2one openerp7
Imagine profil
0
iun. 15
4499
get field.related column from foreign key error - Field '_asdict' does not exist in object browse_record Rezolvat
many2one openerp7 fields.related
Imagine profil
Imagine profil
1
apr. 15
7457
Python - Populating many2one field on loading of form OpenERP
python many2one openerp7
Imagine profil
Imagine profil
1
mar. 15
5889
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now