Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Guest House
    • Drankenhandelaar
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Solar Energy Systems
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC Services
    Others
    • Nonprofit Organization
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

Timesheets multiple days

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
developmentconfiguration
3 Antwoorden
1237 Weergaven
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
Annuleer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste antwoord

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
Annuleer
Avatar
SBB nv
Auteur Beste antwoord

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
Annuleer
Avatar
D Enterprise
Beste antwoord

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
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Dynamic Dashboard Background and Text on Dark/Light Theme Switch in Odoo 16 sh
development configuration
Avatar
Avatar
1
nov. 25
198
Bulk PDF download error
development configuration
Avatar
0
okt. 25
513
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
1001
Google Calendar Sync - Odoo Calendar
development configuration
Avatar
Avatar
Avatar
3
aug. 25
1906
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
1867
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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