Skip to Content

Contributors

Overtime calculation in Odoo 15 and OCA

Hello community,

we are currently looking on overtime calculation in Odoo 15.0. Odoo 15.0 introduced a new model (hr.attendance.overtime) and mechanisms for an overtime calculation. First I want to share our knowledge with digging into it. There are currently some core bugs with the overtime calculation:

  • The resource.calendar from hr.contract is not used for overtime calculation as you would expect if hr_attendance and hr_contract is installed. Causes wrong calculations if you edit attendance before a resource calendar (e.g. somebody forgot to logout and you are validating the attendance)
  • Overtime ignores dates without attendance completly despite it's an actual working day. E.g. if you have to work for 8h and login for 1min you have -7:59h overtime. If you don't login it's +/-0h. This isn't fully consistent.

We are currently trying to develop fixes for these core bugs. The bugs are present from 15.0 to master. We can share the PRs when they are ready.

Following are additional observations regarding the state of the OCA modules in regard to overtime and attendance:

  •  hr_attendance_sheet and hr_attendance_validation: (up to 14.0)
    •  There is a big intersection in the feature sets of both modules. Both are creating a kind of sheet and a multiple step process to verify/approve attendances. They also add features like overtime calculation etc. based on the sheets.
    • A simple migration PR[1] is maybe not worth it because of the core changes in the overtime calculation. E.g. if an approval process is needed shouldn't only approved attendances count towards your overtime?
  • hr_holidays_public: (already 15.0)
    • This module works fine especially the automatic holiday generation with the modules built on top. The module has problems in the overtime calculation. The holidays reduce the days when you request additional holidays. But such a holiday is getting ignored for the overtime calculation. E.g. if you work on a holiday for 9h instead of the regular 8h you get 1h overtime with OCA holiday but 9h for core holiday. It's also not possible to use half holidays (e.g. the 24.12. or 31.12. in Germany). The module also ignores the holidays of the Odoo core. Are there any reasons to stick to the extra model we are not seeing?
    • In 15.0 Odoo core has a own model for public holidays. So just going on we community solution might result in a growing divergence from the core. The feature to generate public holidays is still very comfortable. A new approach could be to rebuild this to create entries of Odoo core model.
  • hr_attendance_report_theoretical_time
    • Here a intersection to the Odoo core overtime calculation in Odoo 15.0 exists, since it comes with some reports (pivot tables).


Is currently somebody else working on it and can share information or experience with overtime in Odoo 15.0 onwards?

Best Regards,

Florian

[1] https://github.com/OCA/hr-attendance/pull/114

-- 
Mit freundlichen Grüßen

Florian Kantelberg
Softwareentwickler

initOS GmbH
Innungsstraße 7
21244 Buchholz i.d.N.

Tel.: +49 (0) 4181 1350344
Fax: +49 (0) 4181 1350310

Email: florian.kantelberg@initos.com
Internet: https://www.initos.com

Geschäftsführung:
Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke

Sitz der Gesellschaft: Buchholz i.d.N.
Amtsgericht: Tostedt, HRB 205226
USt-IdNr: DE 815580155
Steuer-Nr: 15/200/53247

by Florian Kantelberg - 01:50 - 28 Jul 2023

Follow-Ups

  • Re: Overtime calculation in Odoo 15 and OCA
    Hello Akim, hello all!

    After one year, did you finally take this solution for Odoo 16? I'm curious as we are near Odoo 18 and nobody review o migrates this Odoo 15 solutions to Odoo 16 one year before.

    As a resume: 

    1. Odoo FIX several things:
       - [FIX] hr(_contract)(_attendance): Make overtime computation contract-based #159477 https://github.com/odoo/odoo/pull/159477
       - [FIX] hr(_contract)(_attendance): Make overtime computation contract-based #59539 https://github.com/odoo/enterprise/pull/59539
       - [FIX] hr_attendance: Allow contract based overtime computation #168839 https://github.com/odoo/odoo/pull/168839

    2. Florian develop 3 modules

       - hr_attendance_missing_days

       - hr_attendance_overtime_manual

       - hr_holidays_type_visibility
          - Open PR in 15: https://github.com/OCA/hr-holidays/pull/86
          - No migration to 16


    It seems that the OCA solution is not widely used by everyone.

    Thank you for your feedback.

    Best regards,
    Rafael


    El mié, 18 oct 2023 a las 17:02, Akim Juillerat (<notifications@odoo-community.org>) escribió:
    Hello

    I'm a bit late on the topic but was pleasantly surprised to see some other people in the OCA having worked on these issues.

    Going through all the exchanges here, my feeling is that https://github.com/OCA/hr-attendance/pull/140 and https://github.com/OCA/hr-holidays/pull/87 can a go a long way in solving the core issues from Odoo standard.

    However, as we are working on a v16.0 project, did anyone already spend time on migrating these modules?

    We might do it if the testing in v15 matches our client's request, but I prefer to ask before starting.

    Anyway, huge thanks to all the contributors for the good job.

    camptocamp
    INNOVATIVE SOLUTIONS
    BY OPEN SOURCE EXPERTS

    Akim Juillerat
    Business solutions
    Software architect
    +41 62 544 03 78

    Camptocamp SA
    Leberngasse 21
    4600 Olten
    Switzerland
    +41 21 619 10 10


    On Thu, Aug 10, 2023 at 2:31 PM Florian Kantelberg <notifications@odoo-community.org> wrote:

    Hello,

    as promised I want to provide links to the PRs we created so far.

    • https://github.com/odoo/odoo/pull/131558
      • This is a core patch to use the resource calendar provided by the hr.contract if the module is also installed to calculate the overtime (hr.attendance.overtime)
    • https://github.com/OCA/hr-attendance/pull/140
      • This is a module which generates the missing pseudo attendances (with hr.attendance.reason) for working days without attendances
      • I already saw that Holger pushed something similar as draft but in the PR is also code which overwrites other places not everyone might want. Also our testing took a bit longer. I hope this isn't a problem for you Holger?
    • https://github.com/OCA/hr-attendance/pull/141
      • hr_attendance_overtime_manual
      • Small gimmick which will be used for our migration between systems to set the initial offsets. We also have other edge cases where this might be useful.
    • https://github.com/OCA/hr-holidays/pull/86
      • hr_holidays_type_visibility
      • Another annoyance was that Odoo hides leave types with a virtual_remaining_leaves <= 0 automatically. To have an even better overview for the employee we made the visibility configurable.

    We would appreciate feedback or if you find bugs. We generally intend to make the Odoo standard models work here to get the most value out of it.

    Best Regards,

    Florian


    Am 10.08.23 um 11:41 schrieb Stefan Wild | sewisoft.de:
    Hi Frederik,

    I get you point of course. What I can add here is, that there is a boolean flag in the attendance record, where you see that it is generated.
    So for that, you are able every time to delete all generated records, if you want. (Perhaps to that time, that Odoo fixes the problem ;-)

    I think to build a working patch, needs a lot of refactoring, because everything of overtime calculation is based on attendance records.
    And the only way to consider them is, when they really exist.

    I also would be more happy, if it wouldn't need such a workaround.
    Anyway, this solution fits to our needs, and I just want to share it with all of you. No force to use it.

    Vielen Dank und viele Grüße

    Stefan Wild
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild



    Am 10.08.23 um 09:17 schrieb Frederik Kramer:

    Hi Stefan,

    grounding your work on Odoo Standard is what we usually do as well, as it limits the upstream work and even more importantly the maintenance effort. However, i am genuinly not a friend of "dirty" work arounds like the one you described, even if that is definitely pragmatic. The reason is simple: Attendance of 0 effectively means, a given employee was attending but technically less than the minimum recordable time. So if the authorities see that record at a given time in the future, they might be tempted to belive there was an error with regard to the recorded time. Moreover an attendenance cron job means, the entry has not been made by the employee or a manager (human), which mit might not be favourable either (with regard to law and credibility of the system).

    Overall i believe, your strategy is pragmatic but less favourable from a legal standpoint.

    So why not patching the standard functionality, so that it calculates "0" when there is no entry and sent this patch for upstream inclusion? I know this is generally a bumpy road with Odoo but to me that would be the best solution for the given problem

    Best Frederik

    Am 09.08.23 um 23:52 schrieb Stefan Wild | sewisoft.de:
    Hello everyone,

    I pained about the same issues, you are all telling about. I just can speak for version 16. Probably 15 too, but I‘am not sure. Our module depends to Odoo Core only.

    Our biggest pain was, that the overtime is not reduced on days without attendance, where you normally have to work. 

    For that problem we found a really simple solution.
    The approach was, when you have attendances, then overtime calculation is correct.
     
    The trick is, we create an attendance with zero time for days, where no attendance entries exist. 

    Therefore we have implemented a cronjob which runs every night and creates missing attendances for days where are no entries. We use here the „generate_series“ method from postgres. 

    You also have got a new field „count_attendance_from“ in employee. Starting from that date, all missing attendances are generated with zero time.

    If anyone is interested, here is a link to the code.
    I just uploaded it to github, while primarily we are using gitlab.

    In this repository there are two more modules. Once for generating public holidays worldwide using pythons holiday library and one module, for updating overtime when creating the holidays later. 

    hr_attendance_no_gaps:
    Module for correct overtime calculation 

    hr_generate_public_holidays:
    Module for generating holidays

    hr_holidays_attendance_overtime:
    Bridge module between hr_attendance and hr_holidays to update overtime.

    We also would contribute them to oca, but haven‘t written any tests yet. Feel free to contribute :)

    Vielen Dank und Viele Grüße

    Stefan Wild 
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de 
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild


    Am 08.08.2023 um 15:11 schrieb Rafael Blasco <notifications@odoo-community.org>:

    

    Hello Florian, Holger:

     

    After testing and testing in runbot I don’t catch up the “issue” for me is working properly.

     

    I will try to test the OCA PR to get in a defined user cases (we can write down) the difference.

     

    Regards

    Rafael

     

     

    De: Holger Brunn <notifications@odoo-community.org>
    Enviado el: martes, 8 de agosto de 2023 7:42
    Para: Contributors <contributors@odoo-community.org>
    Asunto: Re: Overtime calculation in Odoo 15 and OCA

     

    > Is your proposal to transfer times from time-sheet / attendance -> payslip
     
    > CODE according to some rules (like the Salary Rules). I am running older
     
    > version of Odoo and upgrading to 16 ATM and would like to incorporate a
     
    > feature like this.
     
    no, it might be built on top of my proposal though. I'm now exclusively 
    talking about populating hr.attendance.overtime in a way that
     
    overtime = (time recorded in hr.attendance records) - (expected working hours 
    as per working calendar)
     
    holds
     
     
    -- 
    Your partner for the hard Odoo problems
    https://hunki-enterprises.com

    _______________________________________________
    Mailing-List:
    https://odoo-community.org/groups/contributors-15
    Post to:
    mailto:contributors@odoo-community.org
    Unsubscribe:
    https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Dr.-Ing. Frederik Kramer
    Geschäftsführer
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel:   +49 (0) 4181 13503 12
    Fax:   +49 (0) 4181 13503 10
    Mobil: +49 (0) 179 3901819
    
    Email: frederik.kramer@initos.com
    Internet: www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht Tostedt, HRB 205226
    USt-IdNr.: DE815580155
    Steuer-Nr: 15/200/53247

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Mit freundlichen Grüßen
    
    Florian Kantelberg
    Softwareentwickler
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel.: +49 (0) 4181 1350344
    Fax: +49 (0) 4181 1350310
    
    Email: florian.kantelberg@initos.com
    Internet: https://www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht: Tostedt, HRB 205226
    USt-IdNr: DE 815580155
    Steuer-Nr: 15/200/53247

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    by Rafael Blasco (Moduon) - 05:50 - 13 Aug 2024
  • Re: Overtime calculation in Odoo 15 and OCA
    Hello

    I'm a bit late on the topic but was pleasantly surprised to see some other people in the OCA having worked on these issues.

    Going through all the exchanges here, my feeling is that https://github.com/OCA/hr-attendance/pull/140 and https://github.com/OCA/hr-holidays/pull/87 can a go a long way in solving the core issues from Odoo standard.

    However, as we are working on a v16.0 project, did anyone already spend time on migrating these modules?

    We might do it if the testing in v15 matches our client's request, but I prefer to ask before starting.

    Anyway, huge thanks to all the contributors for the good job.

    camptocamp
    INNOVATIVE SOLUTIONS
    BY OPEN SOURCE EXPERTS

    Akim Juillerat
    Business solutions
    Software architect
    +41 62 544 03 78

    Camptocamp SA
    Leberngasse 21
    4600 Olten
    Switzerland
    +41 21 619 10 10


    On Thu, Aug 10, 2023 at 2:31 PM Florian Kantelberg <notifications@odoo-community.org> wrote:

    Hello,

    as promised I want to provide links to the PRs we created so far.

    • https://github.com/odoo/odoo/pull/131558
      • This is a core patch to use the resource calendar provided by the hr.contract if the module is also installed to calculate the overtime (hr.attendance.overtime)
    • https://github.com/OCA/hr-attendance/pull/140
      • This is a module which generates the missing pseudo attendances (with hr.attendance.reason) for working days without attendances
      • I already saw that Holger pushed something similar as draft but in the PR is also code which overwrites other places not everyone might want. Also our testing took a bit longer. I hope this isn't a problem for you Holger?
    • https://github.com/OCA/hr-attendance/pull/141
      • hr_attendance_overtime_manual
      • Small gimmick which will be used for our migration between systems to set the initial offsets. We also have other edge cases where this might be useful.
    • https://github.com/OCA/hr-holidays/pull/86
      • hr_holidays_type_visibility
      • Another annoyance was that Odoo hides leave types with a virtual_remaining_leaves <= 0 automatically. To have an even better overview for the employee we made the visibility configurable.

    We would appreciate feedback or if you find bugs. We generally intend to make the Odoo standard models work here to get the most value out of it.

    Best Regards,

    Florian


    Am 10.08.23 um 11:41 schrieb Stefan Wild | sewisoft.de:
    Hi Frederik,

    I get you point of course. What I can add here is, that there is a boolean flag in the attendance record, where you see that it is generated.
    So for that, you are able every time to delete all generated records, if you want. (Perhaps to that time, that Odoo fixes the problem ;-)

    I think to build a working patch, needs a lot of refactoring, because everything of overtime calculation is based on attendance records.
    And the only way to consider them is, when they really exist.

    I also would be more happy, if it wouldn't need such a workaround.
    Anyway, this solution fits to our needs, and I just want to share it with all of you. No force to use it.

    Vielen Dank und viele Grüße

    Stefan Wild
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild



    Am 10.08.23 um 09:17 schrieb Frederik Kramer:

    Hi Stefan,

    grounding your work on Odoo Standard is what we usually do as well, as it limits the upstream work and even more importantly the maintenance effort. However, i am genuinly not a friend of "dirty" work arounds like the one you described, even if that is definitely pragmatic. The reason is simple: Attendance of 0 effectively means, a given employee was attending but technically less than the minimum recordable time. So if the authorities see that record at a given time in the future, they might be tempted to belive there was an error with regard to the recorded time. Moreover an attendenance cron job means, the entry has not been made by the employee or a manager (human), which mit might not be favourable either (with regard to law and credibility of the system).

    Overall i believe, your strategy is pragmatic but less favourable from a legal standpoint.

    So why not patching the standard functionality, so that it calculates "0" when there is no entry and sent this patch for upstream inclusion? I know this is generally a bumpy road with Odoo but to me that would be the best solution for the given problem

    Best Frederik

    Am 09.08.23 um 23:52 schrieb Stefan Wild | sewisoft.de:
    Hello everyone,

    I pained about the same issues, you are all telling about. I just can speak for version 16. Probably 15 too, but I‘am not sure. Our module depends to Odoo Core only.

    Our biggest pain was, that the overtime is not reduced on days without attendance, where you normally have to work. 

    For that problem we found a really simple solution.
    The approach was, when you have attendances, then overtime calculation is correct.
     
    The trick is, we create an attendance with zero time for days, where no attendance entries exist. 

    Therefore we have implemented a cronjob which runs every night and creates missing attendances for days where are no entries. We use here the „generate_series“ method from postgres. 

    You also have got a new field „count_attendance_from“ in employee. Starting from that date, all missing attendances are generated with zero time.

    If anyone is interested, here is a link to the code.
    I just uploaded it to github, while primarily we are using gitlab.

    In this repository there are two more modules. Once for generating public holidays worldwide using pythons holiday library and one module, for updating overtime when creating the holidays later. 

    hr_attendance_no_gaps:
    Module for correct overtime calculation 

    hr_generate_public_holidays:
    Module for generating holidays

    hr_holidays_attendance_overtime:
    Bridge module between hr_attendance and hr_holidays to update overtime.

    We also would contribute them to oca, but haven‘t written any tests yet. Feel free to contribute :)

    Vielen Dank und Viele Grüße

    Stefan Wild 
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de 
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild


    Am 08.08.2023 um 15:11 schrieb Rafael Blasco <notifications@odoo-community.org>:

    

    Hello Florian, Holger:

     

    After testing and testing in runbot I don’t catch up the “issue” for me is working properly.

     

    I will try to test the OCA PR to get in a defined user cases (we can write down) the difference.

     

    Regards

    Rafael

     

     

    De: Holger Brunn <notifications@odoo-community.org>
    Enviado el: martes, 8 de agosto de 2023 7:42
    Para: Contributors <contributors@odoo-community.org>
    Asunto: Re: Overtime calculation in Odoo 15 and OCA

     

    > Is your proposal to transfer times from time-sheet / attendance -> payslip
     
    > CODE according to some rules (like the Salary Rules). I am running older
     
    > version of Odoo and upgrading to 16 ATM and would like to incorporate a
     
    > feature like this.
     
    no, it might be built on top of my proposal though. I'm now exclusively 
    talking about populating hr.attendance.overtime in a way that
     
    overtime = (time recorded in hr.attendance records) - (expected working hours 
    as per working calendar)
     
    holds
     
     
    -- 
    Your partner for the hard Odoo problems
    https://hunki-enterprises.com

    _______________________________________________
    Mailing-List:
    https://odoo-community.org/groups/contributors-15
    Post to:
    mailto:contributors@odoo-community.org
    Unsubscribe:
    https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Dr.-Ing. Frederik Kramer
    Geschäftsführer
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel:   +49 (0) 4181 13503 12
    Fax:   +49 (0) 4181 13503 10
    Mobil: +49 (0) 179 3901819
    
    Email: frederik.kramer@initos.com
    Internet: www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht Tostedt, HRB 205226
    USt-IdNr.: DE815580155
    Steuer-Nr: 15/200/53247

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Mit freundlichen Grüßen
    
    Florian Kantelberg
    Softwareentwickler
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel.: +49 (0) 4181 1350344
    Fax: +49 (0) 4181 1350310
    
    Email: florian.kantelberg@initos.com
    Internet: https://www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht: Tostedt, HRB 205226
    USt-IdNr: DE 815580155
    Steuer-Nr: 15/200/53247

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    by Akim Juillerat - 05:00 - 18 Oct 2023
  • Re: Overtime calculation in Odoo 15 and OCA
    Hi all,
    
    
    > https://github.com/OCA/hr-attendance/pull/140
    
    > This is a module which generates the missing pseudo attendances (with
    
    > hr.attendance.reason) for working days without attendances I already saw
    
    > that Holger pushed something similar as draft but in the PR is also code
    
    > which overwrites other places not everyone might want. Also our testing
    
    > took a bit longer. I hope this isn't a problem for you Holger?
    
    not at all, if this already fixes your problem, and everyone agrees duration 0 
    attendances are no problem (I think so), I'll just remove the missing days 
    code from my PR and use yours for that instead.
    In the end I just want an agreed on OCA solution for overtime.
    
    Best regards,
    Holger
    
    
    -- 
    Your partner for the hard Odoo problems
    https://hunki-enterprises.com

    by "Holger Brunn" <mail@hunki-enterprises.nl> - 07:51 - 14 Aug 2023
  • Re: Overtime calculation in Odoo 15 and OCA

    Hello,

    as promised I want to provide links to the PRs we created so far.

    • https://github.com/odoo/odoo/pull/131558
      • This is a core patch to use the resource calendar provided by the hr.contract if the module is also installed to calculate the overtime (hr.attendance.overtime)
    • https://github.com/OCA/hr-attendance/pull/140
      • This is a module which generates the missing pseudo attendances (with hr.attendance.reason) for working days without attendances
      • I already saw that Holger pushed something similar as draft but in the PR is also code which overwrites other places not everyone might want. Also our testing took a bit longer. I hope this isn't a problem for you Holger?
    • https://github.com/OCA/hr-attendance/pull/141
      • hr_attendance_overtime_manual
      • Small gimmick which will be used for our migration between systems to set the initial offsets. We also have other edge cases where this might be useful.
    • https://github.com/OCA/hr-holidays/pull/86
      • hr_holidays_type_visibility
      • Another annoyance was that Odoo hides leave types with a virtual_remaining_leaves <= 0 automatically. To have an even better overview for the employee we made the visibility configurable.

    We would appreciate feedback or if you find bugs. We generally intend to make the Odoo standard models work here to get the most value out of it.

    Best Regards,

    Florian


    Am 10.08.23 um 11:41 schrieb Stefan Wild | sewisoft.de:
    Hi Frederik,

    I get you point of course. What I can add here is, that there is a boolean flag in the attendance record, where you see that it is generated.
    So for that, you are able every time to delete all generated records, if you want. (Perhaps to that time, that Odoo fixes the problem ;-)

    I think to build a working patch, needs a lot of refactoring, because everything of overtime calculation is based on attendance records.
    And the only way to consider them is, when they really exist.

    I also would be more happy, if it wouldn't need such a workaround.
    Anyway, this solution fits to our needs, and I just want to share it with all of you. No force to use it.

    Vielen Dank und viele Grüße

    Stefan Wild
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild



    Am 10.08.23 um 09:17 schrieb Frederik Kramer:

    Hi Stefan,

    grounding your work on Odoo Standard is what we usually do as well, as it limits the upstream work and even more importantly the maintenance effort. However, i am genuinly not a friend of "dirty" work arounds like the one you described, even if that is definitely pragmatic. The reason is simple: Attendance of 0 effectively means, a given employee was attending but technically less than the minimum recordable time. So if the authorities see that record at a given time in the future, they might be tempted to belive there was an error with regard to the recorded time. Moreover an attendenance cron job means, the entry has not been made by the employee or a manager (human), which mit might not be favourable either (with regard to law and credibility of the system).

    Overall i believe, your strategy is pragmatic but less favourable from a legal standpoint.

    So why not patching the standard functionality, so that it calculates "0" when there is no entry and sent this patch for upstream inclusion? I know this is generally a bumpy road with Odoo but to me that would be the best solution for the given problem

    Best Frederik

    Am 09.08.23 um 23:52 schrieb Stefan Wild | sewisoft.de:
    Hello everyone,

    I pained about the same issues, you are all telling about. I just can speak for version 16. Probably 15 too, but I‘am not sure. Our module depends to Odoo Core only.

    Our biggest pain was, that the overtime is not reduced on days without attendance, where you normally have to work. 

    For that problem we found a really simple solution.
    The approach was, when you have attendances, then overtime calculation is correct.
     
    The trick is, we create an attendance with zero time for days, where no attendance entries exist. 

    Therefore we have implemented a cronjob which runs every night and creates missing attendances for days where are no entries. We use here the „generate_series“ method from postgres. 

    You also have got a new field „count_attendance_from“ in employee. Starting from that date, all missing attendances are generated with zero time.

    If anyone is interested, here is a link to the code.
    I just uploaded it to github, while primarily we are using gitlab.

    In this repository there are two more modules. Once for generating public holidays worldwide using pythons holiday library and one module, for updating overtime when creating the holidays later. 

    hr_attendance_no_gaps:
    Module for correct overtime calculation 

    hr_generate_public_holidays:
    Module for generating holidays

    hr_holidays_attendance_overtime:
    Bridge module between hr_attendance and hr_holidays to update overtime.

    We also would contribute them to oca, but haven‘t written any tests yet. Feel free to contribute :)

    Vielen Dank und Viele Grüße

    Stefan Wild 
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de 
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild


    Am 08.08.2023 um 15:11 schrieb Rafael Blasco <notifications@odoo-community.org>:

    

    Hello Florian, Holger:

     

    After testing and testing in runbot I don’t catch up the “issue” for me is working properly.

     

    I will try to test the OCA PR to get in a defined user cases (we can write down) the difference.

     

    Regards

    Rafael

     

     

    De: Holger Brunn <notifications@odoo-community.org>
    Enviado el: martes, 8 de agosto de 2023 7:42
    Para: Contributors <contributors@odoo-community.org>
    Asunto: Re: Overtime calculation in Odoo 15 and OCA

     

    > Is your proposal to transfer times from time-sheet / attendance -> payslip
     
    > CODE according to some rules (like the Salary Rules). I am running older
     
    > version of Odoo and upgrading to 16 ATM and would like to incorporate a
     
    > feature like this.
     
    no, it might be built on top of my proposal though. I'm now exclusively 
    talking about populating hr.attendance.overtime in a way that
     
    overtime = (time recorded in hr.attendance records) - (expected working hours 
    as per working calendar)
     
    holds
     
     
    -- 
    Your partner for the hard Odoo problems
    https://hunki-enterprises.com

    _______________________________________________
    Mailing-List:
    https://odoo-community.org/groups/contributors-15
    Post to:
    mailto:contributors@odoo-community.org
    Unsubscribe:
    https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Dr.-Ing. Frederik Kramer
    Geschäftsführer
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel:   +49 (0) 4181 13503 12
    Fax:   +49 (0) 4181 13503 10
    Mobil: +49 (0) 179 3901819
    
    Email: frederik.kramer@initos.com
    Internet: www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht Tostedt, HRB 205226
    USt-IdNr.: DE815580155
    Steuer-Nr: 15/200/53247

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe


    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Mit freundlichen Grüßen
    
    Florian Kantelberg
    Softwareentwickler
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel.: +49 (0) 4181 1350344
    Fax: +49 (0) 4181 1350310
    
    Email: florian.kantelberg@initos.com
    Internet: https://www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht: Tostedt, HRB 205226
    USt-IdNr: DE 815580155
    Steuer-Nr: 15/200/53247

    by Florian Kantelberg - 02:31 - 10 Aug 2023
  • Re: Overtime calculation in Odoo 15 and OCA
    Hi Frederik,

    I get you point of course. What I can add here is, that there is a boolean flag in the attendance record, where you see that it is generated.
    So for that, you are able every time to delete all generated records, if you want. (Perhaps to that time, that Odoo fixes the problem ;-)

    I think to build a working patch, needs a lot of refactoring, because everything of overtime calculation is based on attendance records.
    And the only way to consider them is, when they really exist.

    I also would be more happy, if it wouldn't need such a workaround.
    Anyway, this solution fits to our needs, and I just want to share it with all of you. No force to use it.

    Vielen Dank und viele Grüße

    Stefan Wild
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild



    Am 10.08.23 um 09:17 schrieb Frederik Kramer:

    Hi Stefan,

    grounding your work on Odoo Standard is what we usually do as well, as it limits the upstream work and even more importantly the maintenance effort. However, i am genuinly not a friend of "dirty" work arounds like the one you described, even if that is definitely pragmatic. The reason is simple: Attendance of 0 effectively means, a given employee was attending but technically less than the minimum recordable time. So if the authorities see that record at a given time in the future, they might be tempted to belive there was an error with regard to the recorded time. Moreover an attendenance cron job means, the entry has not been made by the employee or a manager (human), which mit might not be favourable either (with regard to law and credibility of the system).

    Overall i believe, your strategy is pragmatic but less favourable from a legal standpoint.

    So why not patching the standard functionality, so that it calculates "0" when there is no entry and sent this patch for upstream inclusion? I know this is generally a bumpy road with Odoo but to me that would be the best solution for the given problem

    Best Frederik

    Am 09.08.23 um 23:52 schrieb Stefan Wild | sewisoft.de:
    Hello everyone,

    I pained about the same issues, you are all telling about. I just can speak for version 16. Probably 15 too, but I‘am not sure. Our module depends to Odoo Core only.

    Our biggest pain was, that the overtime is not reduced on days without attendance, where you normally have to work. 

    For that problem we found a really simple solution.
    The approach was, when you have attendances, then overtime calculation is correct.
     
    The trick is, we create an attendance with zero time for days, where no attendance entries exist. 

    Therefore we have implemented a cronjob which runs every night and creates missing attendances for days where are no entries. We use here the „generate_series“ method from postgres. 

    You also have got a new field „count_attendance_from“ in employee. Starting from that date, all missing attendances are generated with zero time.

    If anyone is interested, here is a link to the code.
    I just uploaded it to github, while primarily we are using gitlab.

    In this repository there are two more modules. Once for generating public holidays worldwide using pythons holiday library and one module, for updating overtime when creating the holidays later. 

    hr_attendance_no_gaps:
    Module for correct overtime calculation 

    hr_generate_public_holidays:
    Module for generating holidays

    hr_holidays_attendance_overtime:
    Bridge module between hr_attendance and hr_holidays to update overtime.

    We also would contribute them to oca, but haven‘t written any tests yet. Feel free to contribute :)

    Vielen Dank und Viele Grüße

    Stefan Wild 
    Geschäftsführer
    sewisoft.de - Logo

    sewisoft GmbH
    Örtleinsweg 39
    96148 Baunach

    info@sewisoft.de 
    Tel. +49 (0) 160 / 99 11 25 69
    www.sewisoft.de

    Sitz der Gesellschaft: Baunach
    Registergericht: Amtsgericht Bamberg, HRB 8508
    Geschäftsführer: Günter Selbert, Stefan Wild


    Am 08.08.2023 um 15:11 schrieb Rafael Blasco <notifications@odoo-community.org>:

    

    Hello Florian, Holger:

     

    After testing and testing in runbot I don’t catch up the “issue” for me is working properly.

     

    I will try to test the OCA PR to get in a defined user cases (we can write down) the difference.

     

    Regards

    Rafael

     

     

    De: Holger Brunn <notifications@odoo-community.org>
    Enviado el: martes, 8 de agosto de 2023 7:42
    Para: Contributors <contributors@odoo-community.org>
    Asunto: Re: Overtime calculation in Odoo 15 and OCA

     

    > Is your proposal to transfer times from time-sheet / attendance -> payslip
     
    > CODE according to some rules (like the Salary Rules). I am running older
     
    > version of Odoo and upgrading to 16 ATM and would like to incorporate a
     
    > feature like this.
     
    no, it might be built on top of my proposal though. I'm now exclusively 
    talking about populating hr.attendance.overtime in a way that
     
    overtime = (time recorded in hr.attendance records) - (expected working hours 
    as per working calendar)
     
    holds
     
     
    -- 
    Your partner for the hard Odoo problems
    https://hunki-enterprises.com

    _______________________________________________
    Mailing-List:
    https://odoo-community.org/groups/contributors-15
    Post to:
    mailto:contributors@odoo-community.org
    Unsubscribe:
    https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe

    -- 
    Dr.-Ing. Frederik Kramer
    Geschäftsführer
    
    initOS GmbH
    Innungsstraße 7
    21244 Buchholz i.d.N.
    
    Tel:   +49 (0) 4181 13503 12
    Fax:   +49 (0) 4181 13503 10
    Mobil: +49 (0) 179 3901819
    
    Email: frederik.kramer@initos.com
    Internet: www.initos.com
    
    Geschäftsführung:
    Dr.-Ing. Frederik Kramer & Dipl.-Ing. (FH) Torsten Francke
    
    Sitz der Gesellschaft: Buchholz i.d.N.
    Amtsgericht Tostedt, HRB 205226
    USt-IdNr.: DE815580155
    Steuer-Nr: 15/200/53247

    _______________________________________________
    Mailing-List: https://odoo-community.org/groups/contributors-15
    Post to: mailto:contributors@odoo-community.org
    Unsubscribe: https://odoo-community.org/groups?unsubscribe



    by Stefan Wild - 11:40 - 10 Aug 2023