Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Timesheets multiple days

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
developmentconfiguration
3 Replies
1302 Tampilan
Avatar
SBB nv

Hello,

I often work on projects for an entire month. I use the Timesheet app that is connected with my Project and my Sales Order to make an invoice. 


Is it possible to add a start date (eg. 1st of the month),then an end date, so that the timesheets will be filled in with 8 hours a day, each working day of that period? 


I have seen some extra plugins that uses calendar view and a start and end date, but then the total amount of hours are calculated and not the working hours. 


I think that this is not a really specific topic and that more people will find this usefull. 


Thanks 

0
Avatar
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai

Hi,

Please refer to the code below:

Python:


from odoo import models, fields

from datetime import timedelta


class ProjectTask(models.Model):

    _inherit = 'project.task'


    timesheet_start_date = fields.Date(string="Timesheet Start Date")

    timesheet_end_date = fields.Date(string="Timesheet End Date")

    daily_hours = fields.Float(string="Hours per Day", default=8.0)


    def action_create_timesheets(self):

        """

        Automatically generates timesheet entries for each working day

        (Monday to Friday) between the 'timesheet_start_date' and

        'timesheet_end_date' fields defined on the task.


        Each day will be filled with the number of hours defined in

        'daily_hours' field (default 8.0). Timesheet entries are

        created for the current user (must be linked to an employee).


        This method is triggered manually via a button on the task form.


        Raises:

            Skips any task that has missing start or end date.

            Does not check for existing timesheet duplication.

        """

        timesheet_model = self.env['account.analytic.line']

        for task in self:

            if not (task.timesheet_start_date and task.timesheet_end_date):

                continue

            current_date = task.timesheet_start_date

            while current_date <= task.timesheet_end_date:

                if current_date.weekday() < 5:  # Monday to Friday only

                    timesheet_model.create({

                        'name': f'Timesheet for {current_date}',

                        'project_id': task.project_id.id,

                        'task_id': task.id,

                        'unit_amount': task.daily_hours,

                        'date': current_date,

                        'employee_id': self.env.user.employee_id.id,

                        'user_id': self.env.uid,

                    })

                current_date += timedelta(days=1)


XML:


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

    <field name="name">project.task.form.timesheet.autofill</field>

    <field name="model">project.task</field>

    <field name="inherit_id" ref="project.view_task_form2"/>

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

        <xpath expr="//form//header" position="inside">

            <button name="action_create_timesheets"

                    string="Create Timesheets"

                    type="object"

                    class="oe_highlight"/>

        </xpath>

        <xpath expr="//form/sheet/notebook/page[@name='page_timesheets']"

               position="after">

            <page string="Timesheet Autofill">

                <group>

                    <field name="timesheet_start_date"/>

                    <field name="timesheet_end_date"/>

                    <field name="daily_hours"/>

                </group>

            </page>

        </xpath>

    </field>

</record>

Result:

When the button is clicked, timesheets are automatically created based on the provided data.


Hope it helps.

0
Avatar
Buang
Avatar
SBB nv
Penulis Jawaban Terbai

Wow, thanks for the quick reply. This custom module will not work in Odoo Online, but I will defenitely test it on our system. 

Thanks

0
Avatar
Buang
Avatar
D Enterprise
Jawaban Terbai

Hii,

Use a custom module:

Define a form (wizard) to input:

Start Date

End Date

Employee

Project/Task

Logic to fill working days only:

from datetime import timedelta

from odoo import models, fields, api

import datetime


class AutoTimesheetWizard(models.TransientModel):

    _name = 'auto.timesheet.wizard'


    employee_id = fields.Many2one('hr.employee', required=True)

    project_id = fields.Many2one('project.project', required=True)

    task_id = fields.Many2one('project.task', required=False)

    start_date = fields.Date(required=True)

    end_date = fields.Date(required=True)


    def action_fill_timesheets(self):

        user = self.employee_id.user_id

        date = self.start_date

        while date <= self.end_date:

            if date.weekday() < 5: # Monday to Friday (0-4)

                self.env['account.analytic.line'].create({

                    'name': 'Auto-filled timesheet',

                    'project_id': user.id ,

                    'unit_amount': 8,

                    'date': date,

                })

            date += timedelta(days=1)


i hope it is use full

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Dynamic Dashboard Background and Text on Dark/Light Theme Switch in Odoo 16 sh
development configuration
Avatar
Avatar
1
Nov 25
226
Bulk PDF download error
development configuration
Avatar
0
Okt 25
517
I am trying to set up a mass BOM edit. My Python code is giving forbidden opcode(s) error. Odoo 18
development configuration
Avatar
Avatar
Avatar
2
Sep 25
1037
Google Calendar Sync - Odoo Calendar
development configuration
Avatar
Avatar
Avatar
3
Agu 25
1967
How to set up contacts to require confirmation from a significant person when saving a new contact?
development configuration
Avatar
Avatar
Avatar
2
Jul 25
1896
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik 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