Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Server action hr.work.entry

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
payrollhr_payroll
1 Beantwoorden
2570 Weergaven
Avatar
Flavio Hernández

Hello, i'm trying to make a work entry through a server action, code is the next:

for rec in record:

    inicio = rec.date_start

    fin = inicio + datetime.timedelta(days=20)


    fechas = []

    while inicio <= fin:

        if inicio.weekday() in [5, 6]:

            fechas.append(inicio)

        inicio += datetime.timedelta(days=1)

        

    #raise UserError(fechas)

    forms = []

    for fecha in fechas:

        form = {

            'name': 'Entrada',

            'employee_id': rec.x_studio_empleado,

            'work_entry_type_id': 1,

            'date_start': fecha,

            'date_stop': (fecha + datetime.timedelta(minutes=120))

        }

        forms.append(form)

        

    for formi in forms:

        record.env['hr.work.entry'].create(formi)

my intention is to create work entry for new employee so i can take in account weekends for payroll


I'm getting the next error:

ValueError: <class 'psycopg2.ProgrammingError'>: "can't adapt type 'hr.employee'" while evaluating

Do you know o have any idea how can i fix this.

appreciate the help in advance, ty

0
Avatar
Annuleer
Avatar
SunArc Technologies
Beste antwoord

for rec in record:

    inicio = rec.date_start

    fin = inicio + datetime.timedelta(days=20)

    fechas = []

    while inicio <= fin:

        if inicio.weekday() in [5, 6]:  # 5 and 6 represent Saturday and Sunday

            fechas.append(inicio)

        inicio += datetime.timedelta(days=1)

    forms = []

    for fecha in fechas:

        form = {

            'name': 'Entrada',

            'employee_id': rec.x_studio_empleado.id,  # Pass the employee ID

            'work_entry_type_id': 1,

            'date_start': fecha,

            'date_stop': (fecha + datetime.timedelta(minutes=120))

        }

        forms.append(form)

    for formi in forms:

        record.env['hr.work.entry'].create(formi)



Update the employee_id field in your code to use .id

0
Avatar
Annuleer
Flavio Hernández
Auteur

thank you! I actually had to use id but i got another error solved with making date to datetime
for rec in record:
inicio = rec.date_start
fin = inicio + datetime.timedelta(days=366)

fechas = []
while inicio <= fin:
if inicio.weekday() in [0, 6]:
fechas.append(inicio)
inicio += datetime.timedelta(days=1)

#raise UserError(fechas)
forms = []
for fecha in fechas:
newFecha = datetime.datetime.combine(fecha, datetime.time())
form = {
'name': 'Entrada',
'employee_id': rec.x_studio_empleado.id,
'work_entry_type_id': 1,
'date_start': (newFecha - datetime.timedelta(hours=10)),
'date_stop': newFecha
}
forms.append(form)

for formi in forms:
record.env['hr.work.entry'].create(formi)

thats my code if its any use for anyone

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
V10 module payroll how to create basic rules as i deleted accidentally Opgelost
payroll hr_payroll
Avatar
Avatar
1
feb. 22
4102
Payslips: change the quantity field with Python
payroll hr_payroll
Avatar
Avatar
1
jul. 24
7905
Change view in contract to display as Basic instead of wage ?
payroll hr_payroll
Avatar
0
nov. 15
4369
Payroll report error
payroll hr_payroll
Avatar
0
mrt. 15
5216
openerp hr_payroll_period
payroll hr_payroll
Avatar
Avatar
1
mrt. 15
3993
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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