ソースを参照

upd Proyecto y subtareas

erickabrego 9 ヶ月 前
コミット
d7810be872

+ 19 - 0
custom_project/models/project_task.py

@@ -8,12 +8,31 @@ class ProjectTask(models.Model):
 
     x_start_date = fields.Date(string="Fecha inicio")
     x_end_date = fields.Date(string="Fecha final")
+    x_days_duration = fields.Integer(string="Duración (Días)", compute="compute_days_duration", store=True)
+
+    @api.depends("x_start_date","x_end_date")
+    def compute_days_duration(self):
+        for rec in self:
+            if rec.x_start_date and rec.x_end_date:
+                rec.x_days_duration = (rec.x_end_date - rec.x_start_date).days
+            else:
+                rec.x_days_duration = 0
 
     @api.depends('date_deadline', 'planned_date_begin', 'user_ids')
     def _compute_allocated_hours(self):
         for rec in self:
             rec.allocated_hours = 0
 
+    @api.depends('project_id')
+    def _compute_display_in_project(self):
+        for rec in self:
+            rec.display_in_project = True
+
+    @api.depends('project_id', 'parent_id')
+    def _compute_show_display_in_project(self):
+        for rec in self:
+            rec.show_display_in_project = False
+
     @api.onchange("x_start_date")
     def onchange_start_date(self):
         for rec in self:

+ 22 - 2
custom_project/views/project_task.xml

@@ -7,8 +7,16 @@
             <field name="model">project.task</field>
             <field name="inherit_id" ref="project_enterprise.project_task_view_form"/>
             <field name="arch" type="xml">
-<!--                <xpath expr="//field[@name='date_deadline']" position="replace"/>-->
-<!--                <xpath expr="//label[@for='date_deadline']" position="replace"/>-->
+                <xpath expr="//div[@id='date_deadline_and_recurring_task']" position="attributes">
+                    <attribute name="invisible">1</attribute>
+                </xpath>
+                <xpath expr="//label[@for='date_deadline'][1]" position="attributes">
+                    <attribute name="invisible">1</attribute>
+                </xpath>
+
+                <xpath expr="//label[@for='date_deadline'][2]" position="attributes">
+                    <attribute name="invisible">1</attribute>
+                </xpath>
 
                 <xpath expr="//field[@name='recurring_task']" position="replace"/>
 
@@ -20,6 +28,18 @@
                         <field name="recurring_task" nolabel="1" class="ms-0" style="width: fit-content;" widget="boolean_icon" options="{'icon': 'fa-repeat'}" invisible="not active or parent_id" groups="project.group_project_recurring_tasks"/>
                     </div>
 
+                    <field name="x_days_duration"/>
+
+                </xpath>
+                
+                <xpath expr="//field[@name='child_ids']/list//field[@name='date_deadline']" position="attributes">
+                    <attribute name="column_invisible">1</attribute>
+                </xpath>
+
+                <xpath expr="//field[@name='child_ids']/list//field[@name='date_deadline']" position="after">
+                    <field name="x_end_date" column_invisible="1" required="1"/>
+                    <field name="x_start_date" string="Fechas planeadas" required="1" widget="daterange" options="{'end_date_field': 'x_end_date'}" optional="show"/>
+                    <field name="x_days_duration" optional="show"/>
                 </xpath>
 
             </field>