Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to fill a many2one field in openerp

Subscriure's

Get notified when there's activity on this post

This question has been flagged
many2oneopenerp7
3 Respostes
7772 Vistes
Avatar
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
Avatar
Descartar
Avatar
Rihene
Autor Best Answer

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
Avatar
Descartar
Avatar
Akhil P Sivan
Best Answer

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
Avatar
Descartar
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!

Registrar-se
Related Posts Respostes Vistes Activitat
many2one show all the fields
many2one openerp7
Avatar
Avatar
Avatar
2
de febr. 25
9253
Filter only partner as is_company in many2one field on openerp 7 ? Solved
many2one openerp7
Avatar
Avatar
2
de juny 15
8631
Autofill many2one field with the "Owner" id
modules many2one openerp7
Avatar
0
de juny 15
4483
get field.related column from foreign key error - Field '_asdict' does not exist in object browse_record Solved
many2one openerp7 fields.related
Avatar
Avatar
1
d’abr. 15
7421
Python - Populating many2one field on loading of form OpenERP
python many2one openerp7
Avatar
Avatar
1
de març 15
5848
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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