Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5038 Widoki

I want to make a module for task dependencies as used in project management. That is: start to finish, start to start, etc relations.


I have done:

from odoo import models, fields, api
class task_dependency(models.Model):
    _inherit = 'project.task'

    start_date = fields.Date(string='Start Date')
    finish_date = fields.Date(string='Finish Date')
    task_duration = fields.Integer(string='Task Duration in Days')
    finish_to_start = fields.One2many("project.task","name", string = "Finish to Start")
    start_to_finish = fields.One2many("project.task","name", string = "Start to Finish")
    start_to_start = fields.One2many("project.task","name", string = "Start to Start")
    finish_to_finish = fields.One2many("project.task","name", string = "Finish to Finish")

How can I get the finish date of all the records from a one2many relation so I can compare, for example, all the end dates and get the greater (latest) one so I can set that as the start date of the record with the one2many?
Many thanks!!

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

For that you need to iterate loop through all records of One2many field.

start_date = min(start_to_finish.mapped(FIELSTOCOMPARE))

finish_date = max(start_to_finish.mapped(FIELSTOCOMPARE))

In above example, you need to just give FIELSTOCOMPARE as which field of task you need to compare.


I hope it will helpful for you

Regards

Haresh Kansara

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
gru 23
10486
1
wrz 20
3061
1
sty 25
1750
2
cze 24
6330
2
mar 24
1344