Compare commits
2 Commits
16.0
...
16.0-progr
Author | SHA1 | Date | |
---|---|---|---|
|
643c532939 | ||
|
e69fcf224b |
@@ -1 +1,2 @@
|
|||||||
from . import models
|
from . import models
|
||||||
|
from . import wizards
|
||||||
|
@@ -12,18 +12,19 @@
|
|||||||
"summary": "Module containing base fields and views for studies",
|
"summary": "Module containing base fields and views for studies",
|
||||||
# any module necessary for this one to work correctly
|
# any module necessary for this one to work correctly
|
||||||
"depends": [
|
"depends": [
|
||||||
"base",
|
"base",
|
||||||
"partner_firstname"
|
"partner_firstname"
|
||||||
],
|
],
|
||||||
"qweb": [],
|
"qweb": [],
|
||||||
"external_dependencies": {
|
"external_dependencies": {
|
||||||
"python": [],
|
"python": [],
|
||||||
},
|
},
|
||||||
# always loaded
|
# always loaded
|
||||||
"data": [
|
"data": [
|
||||||
# "security/security.xml",
|
# "security/security.xml",
|
||||||
"data/studies_base_data.xml",
|
"data/studies_base_data.xml",
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
|
"wizards/create_progress_status.xml",
|
||||||
"views/study_config_views.xml",
|
"views/study_config_views.xml",
|
||||||
"views/study_study_views.xml",
|
"views/study_study_views.xml",
|
||||||
"views/study_progress_status_views.xml",
|
"views/study_progress_status_views.xml",
|
||||||
@@ -41,4 +42,4 @@
|
|||||||
# and independently installed. Used for synergetic or glue modules.
|
# and independently installed. Used for synergetic or glue modules.
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
"application": False,
|
"application": False,
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,11 @@ class StudyProgressStatus(models.Model):
|
|||||||
('ACTIVE-BUT-NOT-RECRUITING', 'Active mais ne recrute plus'),
|
('ACTIVE-BUT-NOT-RECRUITING', 'Active mais ne recrute plus'),
|
||||||
('COMPLETED', 'Terminée'),
|
('COMPLETED', 'Terminée'),
|
||||||
('WITHDRAWN', 'Annulé')], string="Avancement de l'étude")
|
('WITHDRAWN', 'Annulé')], string="Avancement de l'étude")
|
||||||
actual = fields.Boolean("Statut actuel")
|
actual = fields.Boolean("Statut actuel", compute="_compute_actual")
|
||||||
date_begin = fields.Datetime("Date de début de l'état")
|
date_begin = fields.Datetime("Date de début de l'état")
|
||||||
date_end = fields.Datetime("Date de fin de l'état")
|
date_end = fields.Datetime("Date de fin de l'état")
|
||||||
|
|
||||||
|
@api.depends("date_end")
|
||||||
|
def _compute_actual(self):
|
||||||
|
for record in self:
|
||||||
|
record.actual = (record.date_end is False) or (record.state == "COMPLETED")
|
||||||
|
@@ -19,7 +19,8 @@ class StudyStudy(models.Model):
|
|||||||
"study.progress.status",
|
"study.progress.status",
|
||||||
string="Avancement de l'étude",
|
string="Avancement de l'étude",
|
||||||
domain="[('study_id', '=', id)]",
|
domain="[('study_id', '=', id)]",
|
||||||
) # should be computed to actual progress status
|
compute="_compute_progress_status_id"
|
||||||
|
)
|
||||||
progress_status = fields.One2many(
|
progress_status = fields.One2many(
|
||||||
"study.progress.status", "study_id", "All progress status"
|
"study.progress.status", "study_id", "All progress status"
|
||||||
)
|
)
|
||||||
@@ -83,6 +84,7 @@ class StudyStudy(models.Model):
|
|||||||
updated = fields.Datetime(
|
updated = fields.Datetime(
|
||||||
"Updated", readonly=True, compute="_compute_updated", store=True
|
"Updated", readonly=True, compute="_compute_updated", store=True
|
||||||
)
|
)
|
||||||
|
active = fields.Boolean("Actif", default=True)
|
||||||
|
|
||||||
@api.depends("create_date")
|
@api.depends("create_date")
|
||||||
def _compute_created(self):
|
def _compute_created(self):
|
||||||
@@ -96,7 +98,11 @@ class StudyStudy(models.Model):
|
|||||||
_logger.info(f"Record ID: {record.id}, write_date: {record.write_date}")
|
_logger.info(f"Record ID: {record.id}, write_date: {record.write_date}")
|
||||||
record.updated = record.write_date
|
record.updated = record.write_date
|
||||||
|
|
||||||
active = fields.Boolean("Actif", default=True)
|
@api.depends("progress_status")
|
||||||
|
def _compute_progress_status_id(self):
|
||||||
|
for record in self:
|
||||||
|
unfinished_progress_status = record.progress_status.filtered(lambda x: x.actual == True)
|
||||||
|
record.progress_status_id = unfinished_progress_status.id if len(unfinished_progress_status) == 1 else None
|
||||||
|
|
||||||
def copy(self, default=None):
|
def copy(self, default=None):
|
||||||
default = dict(default or {}, identifier_primary_id=None)
|
default = dict(default or {}, identifier_primary_id=None)
|
||||||
|
@@ -22,4 +22,5 @@ access_study_questionnaire_status_admin,study.questionnaire.status.admin,model_s
|
|||||||
access_study_participant_progress_status_admin,study.participant.progress.status.admin,model_study_participant_progress_status,base.group_user,1,1,1,1
|
access_study_participant_progress_status_admin,study.participant.progress.status.admin,model_study_participant_progress_status,base.group_user,1,1,1,1
|
||||||
access_study_participant_state_admin,study.participant.state.admin,model_study_participant_state,base.group_user,1,1,1,1
|
access_study_participant_state_admin,study.participant.state.admin,model_study_participant_state,base.group_user,1,1,1,1
|
||||||
access_study_questionnaire_response_progress_status_admin,study.questionnaire.response.progress.status.admin,model_study_questionnaire_response_progress_status,base.group_user,1,1,1,1
|
access_study_questionnaire_response_progress_status_admin,study.questionnaire.response.progress.status.admin,model_study_questionnaire_response_progress_status,base.group_user,1,1,1,1
|
||||||
access_study_author_admin,study.author.admin,model_study_author,base.group_user,1,1,1,1
|
access_study_author_admin,study.author.admin,model_study_author,base.group_user,1,1,1,1
|
||||||
|
access_create_progress_status_wizard,create_progress_status_wizard.access,model_create_progress_status,base.group_user,1,1,1,0
|
||||||
|
|
@@ -22,7 +22,12 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Étude">
|
<form string="Étude">
|
||||||
<header>
|
<header>
|
||||||
<!-- action buttons -->
|
<!-- action buttons -->
|
||||||
|
<button name="%(action_create_progress_status_wizard)d"
|
||||||
|
string="Update Status"
|
||||||
|
class="oe_highlight"
|
||||||
|
type="action"
|
||||||
|
/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<div class="oe_button_box" name="button_box">
|
<div class="oe_button_box" name="button_box">
|
||||||
@@ -41,7 +46,7 @@
|
|||||||
<group name="study_status_left">
|
<group name="study_status_left">
|
||||||
<field name="period_start" />
|
<field name="period_start" />
|
||||||
<field name="period_end" />
|
<field name="period_end" />
|
||||||
<field name="progress_status_id" />
|
<field name="progress_status_id" options="{'no_open': True}" />
|
||||||
</group>
|
</group>
|
||||||
<group name="study_status_right">
|
<group name="study_status_right">
|
||||||
|
|
||||||
@@ -96,6 +101,16 @@
|
|||||||
<page string="Notes" name="notes">
|
<page string="Notes" name="notes">
|
||||||
<field name="note" />
|
<field name="note" />
|
||||||
</page>
|
</page>
|
||||||
|
<page string="Progress status" name="progress_status" groups="base.group_no_one">
|
||||||
|
<field name="progress_status" nolabel="1">
|
||||||
|
<tree create="false" delete="false" default_order="date_begin DESC" >
|
||||||
|
<field name="state" />
|
||||||
|
<field name="date_begin" />
|
||||||
|
<field name="date_end" />
|
||||||
|
<field name="actual" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
@@ -125,4 +140,4 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
1
studies_base/wizards/__init__.py
Normal file
1
studies_base/wizards/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import create_progress_status
|
28
studies_base/wizards/create_progress_status.py
Normal file
28
studies_base/wizards/create_progress_status.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class CreateProgressStatus(models.TransientModel):
|
||||||
|
_name = "create.progress.status"
|
||||||
|
_description = "create Progress Status"
|
||||||
|
|
||||||
|
state = fields.Selection([
|
||||||
|
('DRAFT', 'Brouillon'),
|
||||||
|
('NOT-YET-RECRUITING', 'À venir'),
|
||||||
|
('RECRUITING', 'En cours de recrutement'),
|
||||||
|
('ACTIVE-BUT-NOT-RECRUITING', 'Active mais ne recrute plus'),
|
||||||
|
('COMPLETED', 'Terminée'),
|
||||||
|
('WITHDRAWN', 'Annulé')], string="Avancement de l'étude")
|
||||||
|
|
||||||
|
|
||||||
|
def create_progress_status(self):
|
||||||
|
study = self.env["study.study"].browse(self._context.get("active_ids"))
|
||||||
|
study.progress_status_id.date_end = datetime.now()
|
||||||
|
values = {
|
||||||
|
"study_id": study.id,
|
||||||
|
"state": self.state,
|
||||||
|
"date_begin": datetime.now(),
|
||||||
|
"date_end": None,
|
||||||
|
}
|
||||||
|
self.env["study.progress.status"].create(values)
|
||||||
|
study.write({"updated": datetime.now()})
|
30
studies_base/wizards/create_progress_status.xml
Normal file
30
studies_base/wizards/create_progress_status.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="create_progress_status_wizard_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">create.progress.status.wizard.view.form</field>
|
||||||
|
<field name="model">create.progress.status</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Update study progress status">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="state" />
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
<footer>
|
||||||
|
<button string="Update" name="create_progress_status" type="object"
|
||||||
|
class="btn-primary" />
|
||||||
|
<button string="Cancel" class="btn-secondary" special="cancel" />
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record
|
||||||
|
id="action_create_progress_status_wizard" model="ir.actions.act_window">
|
||||||
|
<field name="name">Create Progress Status</field>
|
||||||
|
<field name="res_model">create.progress.status</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="view_id" ref="create_progress_status_wizard_view_form" />
|
||||||
|
<field name="target">new</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
Reference in New Issue
Block a user