Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3681 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 24
2563
1
มี.ค. 15
4097
1
มี.ค. 15
5201
1
ก.พ. 25
1111
1
ก.ค. 22
7382