Files
study-tools/studies_base/models/study_participant.py

51 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo import osv
from odoo.exceptions import UserError
class StudyParticipant(models.Model):
_name = "study.participant"
identifier_primary_id = fields.Char("Identifiant Seintinelles", readonly=True)
part_of = fields.Many2one("study.study", string="Étude", readonly=True)
subject = fields.Many2one(
"res.partner",
string="Contact",
domain=[("category_patient", "=", 1)],
readonly=True,
)
firstname = fields.Char("Prénom", related="subject.firstname")
lastname = fields.Char("Nom", related="subject.lastname")
progress_status = fields.Many2one(
"study.participant.progress.status",
string="Statut de la participation",
readonly=True,
)
state = fields.Many2one(
"study.participant.state", string="État de la participation", readonly=True
)
## Studyparticipant.identifier.author.value
identifier = fields.Char("Identifiants de l'enrôlement", readonly=True)
created = fields.Datetime("Date de création")
updated = fields.Datetime("Date mise à jour")
active = fields.Boolean("Actif", default=True)
@api.depends("write_date")
def _compute_updated(self):
for record in self:
## XXXb0g : the following two lines are to be removed when all records will have been updated during migration
if record.updated:
continue
record.updated = record.write_date
@api.depends("create_date")
def _compute_created(self):
for record in self:
if not record.created:
record.created = record.create_date