Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3719 Visualizzazioni

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

Avatar
Abbandona
Autore Risposta migliore

I got the answer


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


then it worked

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
mag 24
2576
1
mar 15
4106
1
mar 15
5230
1
feb 25
1152
1
lug 22
7413