Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
4869 Zobrazení

Can a timesheet period be locked at a certain point in time so that no new timesheet activities can be entered for that period? For example, I would to have the possibility to lock the previous month on the first day of the new month. This to motivate employees to enter their hours worked in a timely manner :-) 

Avatar
Zrušit
Nejlepší odpověď

Bob,

You can implement this by adding an odoo constraint to check if the start date entered is of previous month then , raise an error...

your constraint: _constraints = [(_check_date_validation, 'YOUR_MESSAGE', ['date_from', 'date_to'])]

method:
def _check_date_validation(self, cr, uid, ids, context=None):

    for self_obj in self.browse(cr, uid, ids, context=context):

        date_from = datetime.strptime(self_obj.date_from, '%d/%m/%Y').date()

        # datetime.now().month is your current month and

        # date_from.month is the month selected in the from date

        if datetime.now().month > date_from.month and date_from.day==1:

            return False (or you can raise exception here only to display custom message)

        elif YOUR OTHER CONDITIONS

            return False (or you can raise exception here only to display custom message)
    return True

Hope it helps!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
pro 24
1094
3
kvě 23
4501
1
říj 22
3370
0
lis 21
2338
1
kvě 21
3002