fix and validated date_deadline
This commit is contained in:
parent
7ab530bd29
commit
799e944112
7 changed files with 26 additions and 52 deletions
|
|
@ -6,16 +6,14 @@
|
|||
'description': """
|
||||
This module ensures that when a parent task's deadline is updated, all child tasks' deadlines are automatically updated to match.
|
||||
""",
|
||||
'author': 'Your Name',
|
||||
'license': 'AGPL-3',
|
||||
'website': 'https://www.yourwebsite.com',
|
||||
'author': 'Bemade',
|
||||
'license': 'LGPL-3',
|
||||
'website': 'https://www.bemade.org',
|
||||
'depends': [
|
||||
'project',
|
||||
'project_enterprise'
|
||||
],
|
||||
'data': [
|
||||
'views/res_config_settings_views.xml',
|
||||
'data/res_config_settings_data.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="default_enable_task_deadline_cascade" model="ir.config_parameter">
|
||||
<field name="key">project_task_date_deadline_cascade_update.enablecascade</field>
|
||||
<field name="value">False</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import project_task
|
||||
from . import res_config_settings
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ProjectTask(models.Model):
|
|||
if not self.child_ids:
|
||||
return
|
||||
|
||||
_logger.info(
|
||||
_logger.debug(
|
||||
'Starting update for all subtasks of: %s (ID: %s)',
|
||||
self.name, self.id
|
||||
)
|
||||
|
|
@ -33,7 +33,7 @@ class ProjectTask(models.Model):
|
|||
'date_deadline': date_deadline,
|
||||
'planned_date_begin': planned_date_begin
|
||||
}
|
||||
_logger.info(
|
||||
_logger.debug(
|
||||
'Updating %d subtasks with values: %s',
|
||||
len(all_subtasks), values
|
||||
)
|
||||
|
|
@ -43,17 +43,36 @@ class ProjectTask(models.Model):
|
|||
def _onchange_date_deadline(self):
|
||||
"""When parent task deadline changes, update all child tasks deadlines and planned dates recursively."""
|
||||
if self.date_deadline and self.child_ids and not self.env.context.get('skip_onchange'):
|
||||
_logger.info('Recursively updating deadline and planned date for all subtasks of: %s', self.name)
|
||||
_logger.debug('Recursively updating deadline and planned date for all subtasks of: %s', self.name)
|
||||
self.with_context(skip_onchange=True)._update_child_dates_recursive(
|
||||
date_deadline=self.date_deadline,
|
||||
planned_date_begin=self.planned_date_begin # Always pass planned_date_begin
|
||||
)
|
||||
|
||||
def write(self, vals):
|
||||
"""Override write to handle date updates from calendar view and form view.
|
||||
|
||||
The calendar view updates dates through write instead of onchange.
|
||||
This ensures the cascade update works in both cases.
|
||||
"""
|
||||
result = super().write(vals)
|
||||
|
||||
# Check if date_deadline or planned_date_begin was updated
|
||||
if ('date_deadline' in vals or 'planned_date_begin' in vals) and not self.env.context.get('skip_write'):
|
||||
for task in self:
|
||||
if task.child_ids:
|
||||
_logger.debug('Write: Recursively updating dates for all subtasks of: %s', task.name)
|
||||
task.with_context(skip_write=True)._update_child_dates_recursive(
|
||||
date_deadline=task.date_deadline,
|
||||
planned_date_begin=task.planned_date_begin
|
||||
)
|
||||
return result
|
||||
|
||||
@api.onchange('planned_date_begin')
|
||||
def _onchange_planned_date_begin(self):
|
||||
"""When parent task planned date changes, update all child tasks planned dates and deadlines recursively."""
|
||||
if self.planned_date_begin and self.child_ids and not self.env.context.get('skip_onchange'):
|
||||
_logger.info('Recursively updating planned date and deadline for all subtasks of: %s', self.name)
|
||||
_logger.debug('Recursively updating planned date and deadline for all subtasks of: %s', self.name)
|
||||
self.with_context(skip_onchange=True)._update_child_dates_recursive(
|
||||
planned_date_begin=self.planned_date_begin,
|
||||
date_deadline=self.date_deadline # Always pass date_deadline
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
enable_task_deadline_cascade = fields.Boolean(
|
||||
string='Enable Task Deadline Cascade',
|
||||
config_parameter='project_task_date_deadline_cascade_update.enablecascade'
|
||||
)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_update_deadline_wizard,access.update.deadline.wizard,model_update_deadline_wizard,project.group_project_user,1,1,1,1
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="res_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.project.task.deadline</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="priority">99</field>
|
||||
<field name="inherit_id" ref="project.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//block[@id='tasks_management']" position="inside">
|
||||
<setting id="task_deadline_cascade" help="Update child tasks deadline when parent deadline changes">
|
||||
<field name="enable_task_deadline_cascade"/>
|
||||
<div class="text-muted">
|
||||
Enable deadline cascade update for project tasks
|
||||
</div>
|
||||
</setting>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue