콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
378 화면

I have a custom datetime columns on the Account Analytic Line for Start_Time and End_Time that I need with updated date and time when the start and stop button is pressed for the timesheet line. The fields are working but I cant seem to find out where to go to customize the functionality of that specific button to extend Odoo's standard functionality to update my custom fields.

This is because Odoo doesn't track the Exact Start and End time for Timesheets, Tickets and Field Service. I need to track this for our customers reporting.


I am Using Version 18.0

아바타
취소
베스트 답변

Hi,

The Timesheet timer is implemented in the module hr_timesheet. The Start/Stop buttons call methods on the model account.analytic.line:action_timer_start() → starts the timer.action_timer_stop() → stops the timer and calculates duration. Those are the methods you need to inherit/extend.


Code:


from odoo import models, fields, api

from datetime import datetime



class AccountAnalyticLine(models.Model):

    _inherit = "account.analytic.line"


    start_time = fields.Datetime("Start Time")

    end_time = fields.Datetime("End Time")


    def action_timer_start(self):

        """Extend standard start timer to log exact start time"""

        res = super().action_timer_start()

        for line in self:

            line.start_time = fields.Datetime.now()

            line.end_time = False  # reset until stopped

        return res


    def action_timer_stop(self):

        """Extend standard stop timer to log exact end time"""

        res = super().action_timer_stop()

        for line in self:

            line.end_time = fields.Datetime.now()

        return res


Hope it helps.

아바타
취소
작성자

I got this to work for the Timesheet timer but why wouldn't this work for the Helpdesk and Field Service/Project Timer? how would those models be different?

베스트 답변

You seem to be looking for the timer.mixin AbstractModel.

In there, next to others, you'll find methods for action_timer_start()action_timer_stop()action_timer_pause() and action_timer_resume().

아바타
취소
관련 게시물 답글 화면 활동
0
5월 25
1226
1
4월 25
1339
1
2월 24
3183
0
10월 24
4346
0
11월 22
2553