Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Custom code: hr_holidays

Naroči se

Get notified when there's activity on this post

This question has been flagged
time-offv18
1 Odgovori
1753 Prikazi
Avatar
huyennx

Hello everyone.

I am creating a list view to display the list of employees on leave. The fields that need to be displayed include employee_id, holiday_status_id, allocated_days, taken_leaves, remaining_balance, department_id, gender, and job_title. I have done the following:
folder report: hr_leave_balance_report.py:

from odoo import models, fields, tools

class HrLeaveBalanceReport(models.Model):

    _name = 'hr.leave.balance.report'

    _description = 'Time Off Balance Report'

    _auto = False

    employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True)

    holiday_status_id = fields.Many2one('hr.leave.type', string='Leave Type', readonly=True)

    allocated_days = fields.Float(string='Allocated Days', readonly=True)

    taken_leaves = fields.Float(string='Taken Leaves', readonly=True)

    remaining_balance = fields.Float(string='Remaining Balance', readonly=True)

    department_id = fields.Many2one('hr.department', string='Department', readonly=True)

    gender = fields.Char(string="Gender", readonly=True)

    job_title = fields.Char(string="Job Title", readonly=True)


    def init(self):

        tools.drop_view_if_exists(self._cr, 'hr_leave_balance_report')


        self._cr.execute("""

            CREATE or REPLACE view hr_leave_balance_report AS (

                SELECT

                    ROW_NUMBER() OVER () AS id,

                    e.id AS employee_id,

                    e.department_id,

                    e.gender,

                    e.job_title,

                    lt.id AS holiday_status_id,

                    COALESCE(SUM(a.number_of_days), 0) AS allocated_days,

                    COALESCE(SUM(l.number_of_days), 0) AS taken_leaves,

                    COALESCE(SUM(a.number_of_days), 0) - COALESCE(SUM(l.number_of_days), 0) AS remaining_balance

                FROM hr_employee e

                CROSS JOIN hr_leave_type lt

                LEFT JOIN hr_leave_allocation a ON a.employee_id = e.id

                    AND a.holiday_status_id = lt.id

                    AND a.state = 'validate'

                LEFT JOIN hr_leave l ON l.employee_id = e.id

                    AND l.holiday_status_id = lt.id

                    AND l.state = 'validate'

                GROUP BY e.id, e.department_id, e.gender, e.job_title, lt.id

            )

        """)

<?xml version="1.0" encoding="utf-8"?>

<odoo>


    <record id="action_hr_leave_balance_report" model="ir.actions.act_window">

        <field name="name">Time Off Balance Report</field>

        <field name="res_model">hr.leave.balance.report</field>

        <field name="view_mode">list</field>

        <field name="help" type="html">

            <p class="o_view_nocontent_smiling_face">

                No Time Off data to display

            </p>

        </field>

    </record>


    <record id="view_hr_leave_balance_report_tree" model="ir.ui.view">

        <field name="name">hr.leave.balance.report.tree</field>

        <field name="model">hr.leave.balance.report</field>

        <field name="arch" type="xml">

            <list string="Time Off Balance Report">

                <field name="employee_id" />

                <field name="gender" />

                <field name="holiday_status_id" />

                <field name="allocated_days" />

                <field name="taken_leaves" />

                <field name="remaining_balance" />

                <field name="department_id" />

                <field name="job_title" />

            </list>

        </field>

    </record>


    <menuitem

        id="menu_hr_leave_balance_report"

        name="Time Off Balance Report"

        parent="hr_holidays.menu_hr_holidays_report"

        action="action_hr_leave_balance_report" />

</odoo>

but I encountered an error:

RPC_ERROR

Odoo Server Error

Occured on localhost:8069 on model hr.leave.balance.report and id 19 on 2025-05-24 10:01:48 GMT

Traceback (most recent call last):

  File "C:\odoo\Odoo18\odoo\value.id

           ^^^^^^^^

AttributeError: '_unknown' object has no attribute 'id'

The above server error caused the following client error:

OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)

    Error: An error occured in the owl lifecycle (see this Error's "cause" property)

        at handleError (http://localhost:8069/web/assets/8ba1529/web.assets_web.min.js:952:101)

        at App.handleError (http://localhost:8069/web/assets/8ba1529/web.assets_web.min.js:1595:29)

        at ComponentNode.initiateRender (http://localhost:8069/web/assets/8ba1529/web.assets_web.min.js:1044:19)

Caused by: RPC_ERROR: Odoo Server Error

    RPC_ERROR

        at makeErrorFromResponse (http://localhost:8069/web/assets/8ba1529/web.assets_web.min.js:3116:163)

        at XMLHttpRequest.<anonymous> (http://localhost:8069/web/assets/8ba1529/web.assets_web.min.js:3121:13)

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Leave days based on seniority - Time off Solved
time-off v18
Avatar
Avatar
Avatar
2
jul. 25
1121
Change Sign & Pay Button on Quotation E-mails
v18
Avatar
Avatar
Avatar
Avatar
3
nov. 25
318
Problem including JS asset in v18
v18
Avatar
Avatar
Avatar
3
nov. 25
8320
Is it possible to sell on credit directly at the point of sale and leave the order pending payment?
v18
Avatar
Avatar
2
sep. 25
744
How to segrigate a product into multiple products & at the same time i have to manufacture that product also with separate BOM? Solved
v18
Avatar
Avatar
1
jun. 25
1911
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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