Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Can a Timesheet period be locked for further entry of activities?

By
Bob
on 10/10/15, 12:52 PM 448 views

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 :-) 

0

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 10/12/15, 6:07 AM

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!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/10/15, 12:52 PM
Seen: 448 times
Last updated: 10/12/15, 8:37 AM