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č

Timesheets multiple days

Naroči se

Get notified when there's activity on this post

This question has been flagged
developmentconfiguration
3 Odgovori
1351 Prikazi
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
Opusti
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

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
Opusti
Avatar
SBB nv
Avtor Best Answer

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
Opusti
Avatar
D Enterprise
Best Answer

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
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
Dynamic Dashboard Background and Text on Dark/Light Theme Switch in Odoo 16 sh
development configuration
Avatar
Avatar
1
nov. 25
323
Bulk PDF download error
development configuration
Avatar
0
okt. 25
545
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
1111
Google Calendar Sync - Odoo Calendar
development configuration
Avatar
Avatar
Avatar
3
avg. 25
2047
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
1956
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