Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Custom code: hr_holidays

Subscribe

Get notified when there's activity on this post

This question has been flagged
time-offv18
1 Reply
1711 Views
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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Leave days based on seniority - Time off Solved
time-off v18
Avatar
Avatar
Avatar
2
जुल॰ 25
1097
Change Sign & Pay Button on Quotation E-mails
v18
Avatar
Avatar
Avatar
Avatar
3
नव॰ 25
231
Problem including JS asset in v18
v18
Avatar
Avatar
Avatar
3
नव॰ 25
8149
Is it possible to sell on credit directly at the point of sale and leave the order pending payment?
v18
Avatar
Avatar
2
सित॰ 25
714
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
जून 25
1865
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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