diff --git a/models/scop_instance.py b/models/scop_instance.py index f414e0d7a282b43d71325818634e44917cf7043b..bbf3f5fd14995c7f010585fa23dcd6fecc8d3345 100644 --- a/models/scop_instance.py +++ b/models/scop_instance.py @@ -17,6 +17,10 @@ class ScopInstance(models.Model): all_exo_validated = fields.Boolean( compute="_compute_all_exo_validated", default=False ) + number_exo = fields.Integer( + string="Nombre d'exo", + compute="_compute_number_exo" + ) # ------------------------------------------------------ # Computed fields / Search Fields @@ -29,6 +33,10 @@ class ScopInstance(models.Model): else: instance.all_exo_validated = False + def _compute_number_exo(self): + for instance in self: + instance.number_exo = len(instance.exo_ids) + # ------------------------------------------------------ # Button # ------------------------------------------------------ diff --git a/views/scop_instance.xml b/views/scop_instance.xml index 16df386e57a97cd3ff8b7366b2b9d28f85666cd8..ebf58c0168f0c749b37d42be4fa179826e649d26 100644 --- a/views/scop_instance.xml +++ b/views/scop_instance.xml @@ -3,7 +3,7 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> <data> - + <!-- FORM VIEW --> <record id="scop_instance_exo_form_view" model="ir.ui.view"> <field name="name">scop.instance.exo.form</field> <field name="model">scop.instance</field> @@ -68,5 +68,18 @@ </field> </record> + <!-- TREE VIEW --> + <record id="scop_instance_exo_tree_view" model="ir.ui.view"> + <field name="name">scop.instance.exo.tree.inherit</field> + <field name="model">scop.instance</field> + <field name="priority" eval="60" /> + <field name="inherit_id" ref="cgscop_instance.scop_instance_tree_view" /> + <field name="arch" type="xml"> + <xpath expr="//field[@name='date']" position="after"> + <field name="number_exo" /> + </xpath> + </field> + </record> + </data> </odoo>