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

Creating automatic leave allocation based on confirmation date

Abonare

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

Această întrebare a fost marcată
employeeleaveallocationValidationError
1 Răspunde
3339 Vizualizări
Imagine profil
Imran ahmed
Trying to create leave allocation based on a field in hr.employee model.
    @api.onchange('confirm_date')
    def _onchange_confirm_date(self):
        if self.confirm_date:
         
            # Create sick leave allocation
            self.env['hr.leave.allocation'].create({
                'name': 'Automatic Sick Leave Allocation',
                # 'holiday_status_id':
self.env.ref('hr_holidays.holiday_status_sl').id,
                'holiday_status_id': 1,
                'holiday_type': 'employee',
                # 'employee_ids': [(4, self.id)],
                'employee_ids': 20,
                'employee_company_id': 1,
                'department_id': 3,
​ ​ ​'number_of_days': 15.0,
                'state': 'draft',
                'allocation_type': 'regular',
                'date_from': '2024-01-21',
                'date_to': '2024-12-21',
            }) it's giving me the validation error: The employee, department, company or employee category of this request is missing. Please make sure that your user login is linked to an employee.
Here is the sql constraints causing the error:

    _sql_constraints = [
        ('type_value',
         "CHECK( (holiday_type='employee' AND (employee_id IS NOT NULL OR multi_employee IS TRUE)) or "
         "(holiday_type='category' AND category_id IS NOT NULL) or "
         "(holiday_type='department' AND department_id IS NOT NULL) or "         "(holiday_type='company' AND mode_company_id IS NOT NULL))",
         "The employee, department, company or employee category of this request is missing. Please make sure that your user login is linked to an employee."),
        ('duration_check', "CHECK( ( number_of_days > 0 AND allocation_type='regular') or (allocation_type != 'regular'))", "The duration must be greater than 0."),
    ] what am i doing wrong here?
0
Imagine profil
Abandonează
Imagine profil
Cybrosys Techno Solutions Pvt.Ltd
Cel mai bun răspuns

Hi,

The error message indicates that the employee, department, company, or employee category is missing from your leave allocation record. This is due to the SQL constraint in the hr. leave. allocation model.

@api.onchange('confirm_date')
def _onchange_confirm_date(self):
if self.confirm_date:
    # Create sick leave allocation
    leave_allocation_data = {
        'name': 'Automatic Sick Leave Allocation',
        'holiday_status_id': 1, 
        'holiday_type': 'employee',
        'employee_ids': [(4, self.id)], 
        'employee_company_id': self.company_id.id, 
        'department_id': self.department_id.id, 
        'number_of_days': 15.0,
        'state': 'draft',
        'allocation_type': 'regular',
        'date_from': '2024-01-21',
        'date_to': '2024-12-21',
    }

    self.env['hr.leave.allocation'].create(leave_allocation_data)



Following my assumptions about your HR model structure, I've added the employee, company, and department information in this example. Based on your real model structure and requirements, modify the fields as necessary. To meet the SQL requirements, make sure the values you're entering for each field are legitimate.


Hope it helps

0
Imagine profil
Abandonează
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
[RESOLVED] - [Odoo13][Community] - Automatic allocation by month Rezolvat
automatic leave allocation
Imagine profil
Imagine profil
2
ian. 23
11210
What is the difference bewteen "Leave" and Allocation? Rezolvat
hr attendance leave allocation
Imagine profil
Imagine profil
Imagine profil
2
aug. 25
32899
How to inherit a view in a custom module in front end
inheritance custom employee leave
Imagine profil
0
dec. 19
4819
Leave approval access for Manager in V11 Rezolvat
employee leave approval humanresource
Imagine profil
Imagine profil
1
aug. 19
5400
Remaining leave shouldn't be carried over to the next year, can it start over?
leave human_resource holiday allocation
Imagine profil
Imagine profil
1
oct. 18
9500
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