Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте Odoo
    Отримайте програмне забезпечення
    • Завантаження
    • Порівняйте версії
    • Релізи
    Співпрацюйте
    • Github
    • Форум
    • Події
    • Переклади
    • Стати партнером
    • Services for Partners
    • Зареєструйте вашу бухгалтерську фірму
    Отримайте послуги
    • Знайдіть партнера
    • Знайдіть бухгалтера
    • Зустріньтеся з консультантом
    • Послуги з впровадження
    • Референси клієнтів
    • Підтримка
    • Оновлення
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Отримати демо
  • Ціни
  • Допомога

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

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

Is there a workaround for the bug where timesheet entries use incorrect timezone

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
timezonev7attendancetimesheets
2 Відповіді
11250 Переглядів
Аватар
Bill Ennals

There is currently a bug in Timesheets where sign in and out events get timestamped with UTC time rather than the users timezone time. The bug has been confirmed (bugs.launchpad.net/openobject-addons/+bug/1179893).

It creates a significant impediment to implementing OpenERP 7 in my workplace as Timesheet management would be a major reason to do so. Is there some way I can work around this bug in the meantime? I thought about 'pretending' we were in UTC timezone but I think that will create confusion with workers and other problems elsewhere. The bug has only been given low priority so it may take some time to fix.

Bill

2
Аватар
Відмінити
Bill Ennals
Автор

Well, I tried messing around with the system timezone to try and compensate for this bug but it messed too many other things up, like email times and dates, file modification dates etc. It seems like this should be such an easy bug to fix, though I would have no idea how. Can't one of you coding gurus come to the rescue?:)

gunnar

we are having a similar issue with Attendances being messed up (I think same UTC issue is the core of our problem as well) http://help.openerp.com/question/31908/how-to-get-attendance-be-assigned-to-the-correct-day-for-anyone-who-is-not-in-the-utc-timezone. In our case we want a report for Attendances (to show overtime worked in a monthly report to all employees). To overcome this issue (at least on the surface) we kind of fake the output time & date in the pdf report that is being generated. Not a real solution but a cosmetical solution that helps us survive for the moment)

gunnar

hi Bill, seems there was a bugfix that solved it for you https://bugs.launchpad.net/openobject-addons/+bug/1179893. Would you mind to post a short how-to here how to get that in play? Best it would be dummy-proof I guess.

Аватар
Laura Jarvenpaa
Найкраща відповідь

The problem is not that attendances are timestamped in utc (all the times are timestamped in utc in OpenERP) but the fact that OpenERP developers have not realized on which things this kind of forcing openERP to use utc time in database affects. Because timezone problems are like ripples, first they look really small and irrelevant but they grow bigger and bigger...

Anyway, here is temporary solution for your problem however like I said timezone problems are like ripples and you may encounter them in future in many places where you are not expecting them so be prepared for that. And as I don't use timesheets myself I didn't test this totally I just checked that the problem you described doesn't appear anymore. I.e., I made this fix just out of curiosity not because it would help me so test it properly.

And remember, this trick is just what it is: a trick which makes it look like the problem is solved but it isn't fully solved. So this solution is like a painkiller it removes the pain but doesn't remove the reason for the pain.

  1. Remove all you attendance data (old data is not updated so they will still appear on the wrong sheet even after this modification so you have to remove it).

  2. Open file [path to your openerp addons]/hr_timesheet_sheet/hr_timesheet_sheet.py It would be better to do your own module, that inherits from existing implementation, for this because as you update your OpenERP all these changes done directly to the source code will vanish.

In the beginning of file add:

import pytz

pytz is a python module for handling timezones. Then go to line 367 (this is in class hr_attendance in function _sheet)

there is for loop looking like this:

for attendance in self.browse(cursor, user, ids, context=context):
        date_to = datetime.strftime(datetime.strptime(attendance.name[0:10], '%Y-%m-%d'), '%Y-%m-%d %H:%M:%S')
        sheet_ids = sheet_obj.search(cursor, user,
            [('date_to', '>=', date_to), ('date_from', '<=', attendance.name),
             ('employee_id', '=', attendance.employee_id.id)],
            context=context)
        if sheet_ids:
            # [0] because only one sheet possible for an employee between 2 dates
            res[attendance.id] = sheet_obj.name_get(cursor, user, sheet_ids, context=context)[0]

add these line to this loop

        cursor.execute("select rp.tz as tz from res_partner as rp, res_users as ru where ru.id=%s  and ru.partner_id=rp.id", (user,))
        tz = cursor.dictfetchall()
        tz = pytz.timezone(tz[0]['tz']) or pytz.utc

        DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
        date_from = pytz.utc.localize(datetime.strptime(attendance.name, DATETIME_FORMAT)).astimezone(tz)
        date_to = pytz.utc.localize(datetime.strptime(date_to, DATETIME_FORMAT)).astimezone(tz)

So the final version of this for loop looks like this

for attendance in self.browse(cursor, user, ids, context=context):
        date_to = datetime.strftime(datetime.strptime(attendance.name[0:10], '%Y-%m-%d'), '%Y-%m-%d %H:%M:%S')

        cursor.execute("select rp.tz as tz from res_partner as rp, res_users as ru where ru.id=%s  and ru.partner_id=rp.id", (user,))
        tz = cursor.dictfetchall()
        tz = pytz.timezone(tz[0]['tz']) or pytz.utc

        DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
        date_from = pytz.utc.localize(datetime.strptime(attendance.name, DATETIME_FORMAT)).astimezone(tz)
        date_to = pytz.utc.localize(datetime.strptime(date_to, DATETIME_FORMAT)).astimezone(tz)

        sheet_ids = sheet_obj.search(cursor, user,
            [('date_to', '>=', date_to), ('date_from', '<=', date_from),
             ('employee_id', '=', attendance.employee_id.id)],
            context=context)
        if sheet_ids:
            # [0] because only one sheet possible for an employee between 2 dates                                                                        
            res[attendance.id] = sheet_obj.name_get(cursor, user, sheet_ids, context=context)[0]

NOTE: in python indentation matters so copy pasting this to your code may cause indentation failures so be sure that indentation are right (I'm not sure how much you have experience about python so thought that this is good to mention).

3.Restart your openERP server with parameter -u hr_timesheet_sheet so that hr_timesheet_sheet module is updated.

1
Аватар
Відмінити
Bill Ennals
Автор

Thanks for your response Laura. I will give it a try when I get a chance, but as you say, if it gets overwritten whenever I update OpenERP it's of limited use. I get the feeling the developers are close to resolving the problem though.

Laura Jarvenpaa

Good if they are solving it. As I said you can also create a separate module which defines new version of this _sheet function and inherits from the original implementation so that everythime this _sheet function is called it calls this new version instead of the old one. Then changes doesn't vanish when you update your OpenERP but if you haven't done modules by yourself before it may take some time so it is better if the developers get this fixed by themselves.

Matt Taylor

This fixes only one of the problems. There are a few other problems with timezones in hr_timesheet_sheet. I submitted a patch at https://bugs.launchpad.net/openobject-addons/+bug/1179893

Аватар
Mohamed
Найкраща відповідь

my file is different from urs, i cant find (for attendance in self.browse(cursor, user, ids, context=context):
......) . im using openerp v7.0

0
Аватар
Відмінити
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Реєстрація
Related Posts Відповіді Переглядів Дія
Attendances not using correct timezone
timezone attendance
Аватар
Аватар
1
лип. 24
4556
Best Practices for Integrating Attendance with Time Sheets in Odoo
attendance timesheets
Аватар
1
черв. 25
3089
how to get attendance be assigned to the correct day? for anyone who is not in the UTC timezone
hr timezone attendance
Аватар
Аватар
Аватар
2
лип. 24
10027
Time of check in and check out in attendance is two hours later than assigned in code Вирішено
timezone time attendance
Аватар
Аватар
1
груд. 23
2605
Import attendance in UTC Вирішено
timezone attendance importing
Аватар
1
серп. 21
3549
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція Odoo - це одночасно дуже проста у використанні та повністю інтегрована.

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