Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to fill a many2one field in openerp

Odoberať

Get notified when there's activity on this post

This question has been flagged
many2oneopenerp7
3 Replies
7823 Zobrazenia
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
Zrušiť
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
Zrušiť
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
Zrušiť
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!

Registrácia
Related Posts Replies Zobrazenia Aktivita
many2one show all the fields
many2one openerp7
Avatar
Avatar
Avatar
2
feb 25
9312
Filter only partner as is_company in many2one field on openerp 7 ? Solved
many2one openerp7
Avatar
Avatar
2
jún 15
8665
Autofill many2one field with the "Owner" id
modules many2one openerp7
Avatar
0
jún 15
4508
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
apr 15
7475
Python - Populating many2one field on loading of form OpenERP
python many2one openerp7
Avatar
Avatar
1
mar 15
5898
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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