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

I have created custom field in an existing model.


class Project_task_custom(models.Model):

    _inherit = "project.task"

    # inserting new field to project.task model

    customfield = fields.Integer("custom")


But How can I get existing field to calculate?


I want to get a field "__last_update" from related model such as account.analytic.line

And I want to compare them which one is latest one.

Then show the latest update time


I've made some code to archive it below


    @api.one

    @api.depends('timesheet_ids')

    def _get_has_timesheet(self):

        self.has_timesheet = bool(self.timesheet_ids)

    has_timesheet = fields.Boolean(compute="_get_has_timesheet", help="Technical field used for usability purposes")


Please help

아바타
취소
작성자 베스트 답변

I got the answer


I should remove @api.depends("timesheet_ids")


then it worked

아바타
취소
관련 게시물 답글 화면 활동
1
5월 24
2617
1
3월 15
4132
1
3월 15
5267
1
2월 25
1177
1
7월 22
7454