6 Commits

Author SHA1 Message Date
Boris Gallet
8cb35a4640 [FIX] studies_base: handle get_name for recordsets 2025-07-28 15:24:56 +02:00
Boris Gallet
7e3946588d [FIX] studies_base: handle create and write date 2025-07-23 15:52:31 +02:00
Stéphan Sainléger
7b7031bb15 [FIX] studies_base: transforms progess status period dates in datetime fields 2025-07-21 09:51:43 +02:00
Stéphan Sainléger
202490a52e [FIX] studies_base: #OPP308 transforms study period dates in datetime fields 2025-07-21 09:51:31 +02:00
Boris Gallet
3b1800a6bf [FIX] studies_base: change correct date and name for questionnaire 2025-07-08 16:14:12 +02:00
Boris Gallet
99e3a22877 [FIX] studies_base: #OPP315 clean study name 2025-07-08 15:34:24 +02:00
5 changed files with 132 additions and 54 deletions

View File

@@ -18,5 +18,5 @@ class StudyProgressStatus(models.Model):
('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")
date_begin = fields.Date("Date de début de l'état") date_begin = fields.Datetime("Date de début de l'état")
date_end = fields.Date("Date de fin de l'état") date_end = fields.Datetime("Date de fin de l'état")

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from odoo import api, fields, models, _ from odoo import api, fields, models
from odoo import osv
from odoo.exceptions import UserError
class StudyQuestionnaire(models.Model): class StudyQuestionnaire(models.Model):
@@ -35,11 +33,34 @@ class StudyQuestionnaire(models.Model):
copyright = fields.Text("Copyright") copyright = fields.Text("Copyright")
copyright_label = fields.Char("Propriétaire et année du copyright") copyright_label = fields.Char("Propriétaire et année du copyright")
created = fields.Datetime("Created") created = fields.Datetime("Created", compute="_compute_created", readonly=True)
date = fields.Datetime("Date") date = fields.Datetime("Date", compute="_compute_updated", readonly=True)
@api.depends("create_date")
def _compute_created(self):
for record in self:
if not record.created:
record.created = record.create_date
@api.depends("write_date")
def _compute_updated(self):
for record in self:
record.date = record.write_date
active = fields.Boolean("Actif", default=True) active = fields.Boolean("Actif", default=True)
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)
return super().copy(default) return super().copy(default)
@api.depends("title", "name")
def name_get(self):
result = []
for questionnaire in self:
if not questionnaire.name:
result.append((questionnaire.id, questionnaire.title))
else:
result.append(
(questionnaire.id, f"[{questionnaire.name}] {questionnaire.title}")
)
return result

View File

@@ -2,6 +2,9 @@
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo import osv from odoo import osv
from odoo.exceptions import UserError from odoo.exceptions import UserError
import logging
_logger = logging.getLogger(__name__)
class StudyStudy(models.Model): class StudyStudy(models.Model):
@@ -10,10 +13,12 @@ class StudyStudy(models.Model):
title = fields.Char("Nom de l'étude") title = fields.Char("Nom de l'étude")
name = fields.Char("Acronyme") name = fields.Char("Acronyme")
period_start = fields.Date("Début de l'étude") period_start = fields.Datetime("Début de l'étude")
period_end = fields.Date("Fin de l'étude") period_end = fields.Datetime("Fin de l'étude")
progress_status_id = fields.Many2one( progress_status_id = fields.Many2one(
"study.progress.status", string="Avancement de l'étude" "study.progress.status",
string="Avancement de l'étude",
domain="[('study_id', '=', id)]",
) # should be computed to actual progress status ) # should be computed to actual progress status
progress_status = fields.One2many( progress_status = fields.One2many(
"study.progress.status", "study_id", "All progress status" "study.progress.status", "study_id", "All progress status"
@@ -72,8 +77,24 @@ class StudyStudy(models.Model):
note = fields.Text("Annotations") note = fields.Text("Annotations")
created = fields.Datetime("Created") created = fields.Datetime(
updated = fields.Datetime("Updated") "Created", readonly=True, compute="_compute_created", store=True
)
updated = fields.Datetime(
"Updated", readonly=True, compute="_compute_updated", store=True
)
@api.depends("create_date")
def _compute_created(self):
for record in self:
if not record.created:
record.created = record.create_date
@api.depends("write_date")
def _compute_updated(self):
for record in self:
_logger.info(f"Record ID: {record.id}, write_date: {record.write_date}")
record.updated = record.write_date
active = fields.Boolean("Actif", default=True) active = fields.Boolean("Actif", default=True)
@@ -81,6 +102,13 @@ class StudyStudy(models.Model):
default = dict(default or {}, identifier_primary_id=None) default = dict(default or {}, identifier_primary_id=None)
return super().copy(default) return super().copy(default)
@api.depends("title", "name")
def name_get(self): @api.depends("title", "name")
return [(study.id, f"[{study.name}] {study.title}") for study in self] def name_get(self):
result = []
for study in self:
if not study.name:
result.append((study.id, study.title))
else:
result.append((study.id, f"[{study.name}] {study.title}"))
return result

View File

@@ -3,13 +3,13 @@
<!-- TREE VIEW --> <!-- TREE VIEW -->
<record id="view_study_questionnaire_tree" model="ir.ui.view"> <record id="view_study_questionnaire_tree" model="ir.ui.view">
<field name="name">study.questionnaire.tree</field> <field name="name">study.questionnaire.tree</field>
<field name="model">study.questionnaire</field> <field name="model">study.questionnaire</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Questionnaires"> <tree string="Questionnaires">
<field name="title"/> <field name="title"/>
<field name="name"/> <field name="name"/>
<field name="effective_period_start"/> <field name="effective_period_start"/>
<field name="effective_period_end"/> <field name="effective_period_end"/>
</tree> </tree>
</field> </field>
</record> </record>
@@ -17,7 +17,7 @@
<!-- FORM VIEW --> <!-- FORM VIEW -->
<record id="view_study_questionnaire_form" model="ir.ui.view"> <record id="view_study_questionnaire_form" model="ir.ui.view">
<field name="name">study.questionnaire.form</field> <field name="name">study.questionnaire.form</field>
<field name="model">study.questionnaire</field> <field name="model">study.questionnaire</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Questionnaire"> <form string="Questionnaire">
<header> <header>
@@ -27,7 +27,7 @@
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box">
<!-- big buttons --> <!-- big buttons -->
</div> </div>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>
<label for="title" string="Nom du questionnaire" /><field name="title" /> <label for="title" string="Nom du questionnaire" /><field name="title" />
@@ -49,7 +49,7 @@
<group name="description" string="Description"> <group name="description" string="Description">
<group name="description_left"> <group name="description_left">
<field name="purpose" /> <field name="purpose" />
<field name="subject_type" widget="many2many_tags" /> <field name="subject_type" widget="many2many_tags" />
</group> </group>
<group name="description_right"> <group name="description_right">
<field name="description" /> <field name="description" />
@@ -66,29 +66,43 @@
</group> </group>
<group name="technique_right"> <group name="technique_right">
<field name="identifier_primary_id" /> <field name="identifier_primary_id" />
<field name="create_date" /> <field name="created" />
<field name="write_date" /> <field name="date" />
</group> </group>
</group> </group>
<notebook> <notebook>
<page string="Copyright" name="copyright"> <page string="Copyright" name="copyright">
<group name="copyright"> <group name="copyright">
<field name="copyright" /> <field name="copyright" />
<field name="copyright_label" /> <field name="copyright_label" />
</group> </group>
</page> </page>
</notebook> </notebook>
</sheet> </sheet>
</form> </form>
</field> </field>
</record> </record>
<!-- ACTIONS --> <!-- ACTIONS -->
<record id="action_study_questionnaire" model="ir.actions.act_window"> <record id="action_study_questionnaire" model="ir.actions.act_window">
<field name="name">Questionnaires</field> <field name="name">Questionnaires</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">study.questionnaire</field> <field name="res_model">study.questionnaire</field>
</record>
<!-- SEARCH VIEW -->
<record id="view_study_questionnaire_search" model="ir.ui.view">
<field name="name">study.questionnaire.search</field>
<field name="model">study.questionnaire</field>
<field name="arch" type="xml">
<search string="Questionnaires">
<field name="title" string="Nom"/>
<field name="name" string="Acronyme"/>
<field name="identifier_primary_id" string="Seintinelles ID"/>
<field name="effective_period_start" string="Effective Start"/>
<field name="effective_period_end" string="Effective End"/>
</search>
</field>
</record> </record>
</odoo> </odoo>

View File

@@ -3,14 +3,14 @@
<!-- TREE VIEW --> <!-- TREE VIEW -->
<record id="view_study_study_tree" model="ir.ui.view"> <record id="view_study_study_tree" model="ir.ui.view">
<field name="name">study.study.tree</field> <field name="name">study.study.tree</field>
<field name="model">study.study</field> <field name="model">study.study</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Études"> <tree string="Études">
<field name="title"/> <field name="title"/>
<field name="name"/> <field name="name"/>
<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"/>
</tree> </tree>
</field> </field>
</record> </record>
@@ -18,7 +18,7 @@
<!-- FORM VIEW --> <!-- FORM VIEW -->
<record id="view_study_study_form" model="ir.ui.view"> <record id="view_study_study_form" model="ir.ui.view">
<field name="name">study.study.form</field> <field name="name">study.study.form</field>
<field name="model">study.study</field> <field name="model">study.study</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Étude"> <form string="Étude">
<header> <header>
@@ -28,7 +28,7 @@
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box">
<!-- big buttons --> <!-- big buttons -->
</div> </div>
<div class="oe_title"> <div class="oe_title">
<h1> <h1>
<label for="title" string="Nom de l'étude" /><field name="title" /> <label for="title" string="Nom de l'étude" /><field name="title" />
@@ -44,18 +44,18 @@
<field name="progress_status_id" /> <field name="progress_status_id" />
</group> </group>
<group name="study_status_right"> <group name="study_status_right">
</group> </group>
</group> </group>
<group name="description" string="Description"> <group name="description" string="Description">
<group name="description_left"> <group name="description_left">
<field name="description_summary" /> <field name="description_summary" />
<field name="description" /> <field name="description" />
<field name="keywords" widget="many2many_tags" /> <field name="keywords" widget="many2many_tags" />
</group> </group>
<group name="description_right"> <group name="description_right">
<field name="primary_purpose_type" /> <field name="primary_purpose_type" />
<field name="part_of" /> <field name="part_of" />
<field name="version" /> <field name="version" />
<field name="phase" /> <field name="phase" />
<field name="status" /> <field name="status" />
@@ -63,13 +63,13 @@
</group> </group>
<group name="technique" string="Technique"> <group name="technique" string="Technique">
<group name="technique_left"> <group name="technique_left">
<field name="site" /> <field name="site" />
<field name="identifier_author" /> <field name="identifier_author" />
</group> </group>
<group name="technique_right"> <group name="technique_right">
<field name="identifier_primary_id" /> <field name="identifier_primary_id" />
<field name="create_date" /> <field name="created" />
<field name="write_date" /> <field name="updated" />
</group> </group>
</group> </group>
<notebook> <notebook>
@@ -92,7 +92,7 @@
<field name="region" widget="many2many_tags" /> <field name="region" widget="many2many_tags" />
</group> </group>
</group> </group>
</page> </page>
<page string="Notes" name="notes"> <page string="Notes" name="notes">
<field name="note" /> <field name="note" />
</page> </page>
@@ -101,13 +101,28 @@
</form> </form>
</field> </field>
</record> </record>
<!-- ACTIONS --> <!-- ACTIONS -->
<record id="action_study_study" model="ir.actions.act_window"> <record id="action_study_study" model="ir.actions.act_window">
<field name="name">Études</field> <field name="name">Études</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">study.study</field> <field name="res_model">study.study</field>
</record> </record>
<!-- SEARCH-->
<record id="view_study_study_search" model="ir.ui.view">
<field name="name">study.study.search</field>
<field name="model">study.study</field>
<field name="arch" type="xml">
<search string="Études">
<field name="title" string="Nom de l'étude" />
<field name="name" string="Acronyme" />
<field name="identifier_primary_id" string="Seintinelles ID"/>
<field name="period_start" string="Date de début" />
<field name="period_end" string="Date de fin" />
</search>
</field>
</record>
</odoo> </odoo>