Project Changes

This commit is contained in:
pranaysaidurga 2026-06-03 10:55:50 +05:30
parent 604d556501
commit eb17d717dd
5 changed files with 130 additions and 132 deletions

View File

@ -46,7 +46,7 @@ class projectTask(models.Model):
('normal', 'Normal'), ('normal', 'Normal'),
], compute='_compute_deadline_status') ], compute='_compute_deadline_status')
model_id = fields.Many2one('project.module.source', string="Module", related='project_id.module_id', store=True, readonly=True) model_id = fields.Many2one('project.module.source', string="Module", store=True, readonly=True)
task_display_id = fields.Char(string="Task ID", compute="_compute_kanban_display_fields", compute_sudo=True) task_display_id = fields.Char(string="Task ID", compute="_compute_kanban_display_fields", compute_sudo=True)
module_display_name = fields.Char(string="Module", compute="_compute_kanban_display_fields", compute_sudo=True) module_display_name = fields.Char(string="Module", compute="_compute_kanban_display_fields", compute_sudo=True)
allocation_start_date = fields.Date(string="Allocation Start Date") allocation_start_date = fields.Date(string="Allocation Start Date")
@ -54,11 +54,11 @@ class projectTask(models.Model):
reassignment_history = fields.Html(string="Reassignment History", readonly=True) reassignment_history = fields.Html(string="Reassignment History", readonly=True)
@api.depends('sequence_name', 'project_id', 'project_id.module_id', 'project_id.module_id.name', 'model_id', 'model_id.name') @api.depends('sequence_name', 'project_id', 'model_id', 'model_id.name')
def _compute_kanban_display_fields(self): def _compute_kanban_display_fields(self):
for task in self: for task in self:
task.task_display_id = task.sequence_name or ("TASK-%03d" % task.id if task.id else "New Task") task.task_display_id = task.sequence_name or ("TASK-%03d" % task.id if task.id else "New Task")
module = task.model_id or task.project_id.module_id module = task.model_id
task.module_display_name = module.name if module else "No Module" task.module_display_name = module.name if module else "No Module"
@api.depends('date_deadline') @api.depends('date_deadline')
@ -841,7 +841,7 @@ class projectTask(models.Model):
task.stage_id = n_stage task.stage_id = n_stage
task.approval_status = "approved" task.approval_status = "approved"
activity_log = "%s: ✅ approved by %s and moved to %s" % ( activity_log = "%s: approved by %s and moved to %s" % (
current_stage.name, current_stage.name,
self.env.user.employee_id.name, self.env.user.employee_id.name,
n_stage.name) n_stage.name)
@ -849,7 +849,7 @@ class projectTask(models.Model):
# Use the helper method to add activity log # Use the helper method to add activity log
task._add_activity_log(activity_log) task._add_activity_log(activity_log)
user_notes = "%s: ✅ moved to %s and awaiting your completion" % ( user_notes = "%s: moved to %s and awaiting your completion" % (
task.sequence_name, task.sequence_name,
n_stage.name n_stage.name
) )
@ -882,9 +882,9 @@ class projectTask(models.Model):
) )
else: else:
task.approval_status = "approved" task.approval_status = "approved"
notes = "%s: ✅ Task approved and completed by %s" % (task.sequence_name, self.env.user.employee_id.name) notes = "%s: Task approved and completed by %s" % (task.sequence_name, self.env.user.employee_id.name)
activity_log = "%s: ✅ approved by %s" % ( activity_log = "%s: approved by %s" % (
current_stage.name, current_stage.name,
self.env.user.employee_id.name) self.env.user.employee_id.name)
@ -920,9 +920,9 @@ class projectTask(models.Model):
# Optional: find previous stage if you want to send back # Optional: find previous stage if you want to send back
stage = task.assignees_timelines.filtered(lambda s: s.stage_id == task.stage_id) stage = task.assignees_timelines.filtered(lambda s: s.stage_id == task.stage_id)
notes = "%s: ❌ %s rejected by %s" % (task.sequence_name, current_stage.name, self.env.user.employee_id.name) notes = "%s: %s rejected by %s" % (task.sequence_name, current_stage.name, self.env.user.employee_id.name)
activity_log = "%s: ❌ rejected by %s: %s" % ( activity_log = "%s: rejected by %s: %s" % (
current_stage.name, current_stage.name,
self.env.user.employee_id.name, self.env.user.employee_id.name,
reason) reason)

View File

@ -1,49 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data> <data>
<record id="project_project_form_module_inherit" model="ir.ui.view">
<field name="name">project.project.form.module.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project_task_timesheet_extended.project_project_inherit_form_view2"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='project_lead']" position="after">
<field name="module_id" options="{'no_open': True}"/>
</xpath>
</field>
</record>
<record id="project_project_search_project_by_module" model="ir.ui.view">
<field name="name">project.project.search.project.by.module</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.view_project_project_filter"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<filter name="group_by_module" string="Module" context="{'group_by': 'module_id'}"/>
</xpath>
</field>
</record>
<record id="action_project_by_module" model="ir.actions.act_window">
<field name="name">Project by Module</field>
<field name="res_model">project.project</field>
<field name="view_mode">kanban,list,form,calendar,activity</field>
<field name="search_view_id" ref="project.view_project_project_filter"/>
<field name="context">{'search_default_group_by_module': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No projects found.
</p>
<p>
Create projects and set their Module to review projects module-wise.
</p>
</field>
</record>
<menuitem id="menu_project_by_module"
name="Project by Module"
parent="project.menu_main_pm"
action="action_project_by_module"
sequence="25"/>
<record id="project_project_kanban_portfolio_inherit" model="ir.ui.view"> <record id="project_project_kanban_portfolio_inherit" model="ir.ui.view">
<field name="name">project.project.kanban.portfolio.inherit</field> <field name="name">project.project.kanban.portfolio.inherit</field>
@ -79,6 +36,41 @@
</xpath> </xpath>
</field> </field>
</record> </record>
<record id="project_task_search_project_by_module" model="ir.ui.view">
<field name="name">project.task.search.project.by.module</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_search_form"/>
<field name="arch" type="xml">
<xpath expr="//search" position="inside">
<filter name="group_by_module" string="Module" context="{'group_by': 'model_id'}"/>
</xpath>
</field>
</record>
<record id="action_project_by_module" model="ir.actions.act_window">
<field name="name">Project by Module</field>
<field name="res_model">project.task</field>
<field name="view_mode">kanban,list,form,calendar,activity</field>
<field name="search_view_id" ref="project.view_task_search_form"/>
<field name="context">{'search_default_group_by_module': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No projects found.
</p>
<p>
Create projects and set their Module to review projects module-wise.
</p>
</field>
</record>
<menuitem id="menu_project_by_module"
name="Project by Module"
parent="project.menu_main_pm"
action="action_project_by_module"
sequence="25"/>
</data> </data>
</odoo> </odoo>

View File

@ -293,6 +293,7 @@
<record id="project.project_task_kanban_action_view" model="ir.actions.act_window.view"> <record id="project.project_task_kanban_action_view" model="ir.actions.act_window.view">
<field name="view_id" ref="project_task_timesheet_extended.project_task_kanban_task_id_module_project_tasks"/> <field name="view_id" ref="project_task_timesheet_extended.project_task_kanban_task_id_module_project_tasks"/>
</record> </record>
</data> </data>
</odoo> </odoo>

View File

@ -8,7 +8,8 @@ class TaskRejectReasonWizard(models.TransientModel):
reason = fields.Text(string="Rejection Reason", required=True) reason = fields.Text(string="Rejection Reason", required=True)
task_id = fields.Many2one("project.task", string="Task", required=True) task_id = fields.Many2one("project.task", string="Task", required=True)
stage_id = fields.Many2one("project.task.type", string="Return To Stage", required=True) return_to_previous_stages = fields.Boolean(default=False)
stage_id = fields.Many2one("project.task.type", string="Return To Stage",)
available_stage_ids = fields.Many2many("project.task.type", compute="_compute_available_stage_ids") available_stage_ids = fields.Many2many("project.task.type", compute="_compute_available_stage_ids")
@api.depends("task_id", "task_id.project_id", "task_id.stage_id") @api.depends("task_id", "task_id.project_id", "task_id.stage_id")
@ -16,17 +17,20 @@ class TaskRejectReasonWizard(models.TransientModel):
for wizard in self: for wizard in self:
stages = wizard.task_id.project_id.type_ids stages = wizard.task_id.project_id.type_ids
if wizard.task_id.stage_id: if wizard.task_id.stage_id:
stages = stages.filtered(lambda s: s.id != wizard.task_id.stage_id.id) stages = stages.filtered(lambda s: s.id != wizard.task_id.stage_id.id and s.sequence < wizard.task_id.stage_id.sequence)
wizard.available_stage_ids = [(6, 0, stages.ids)] wizard.available_stage_ids = [(6, 0, stages.ids)]
def action_reject(self): def action_reject(self):
self.ensure_one() self.ensure_one()
if not self.reason: if not self.reason:
raise UserError(_("Please enter a reason for rejection.")) raise UserError(_("Please enter a reason for rejection."))
if not self.stage_id: if not self.stage_id and self.return_to_previous_stages:
raise UserError(_("Please select the stage where the task should be returned.")) raise UserError(_("Please select the stage where the task should be returned."))
self.task_id.reject_and_return(reason=self.reason, return_stage=self.stage_id) if self.return_to_previous_stages:
self.task_id.reject_and_return(reason=self.reason, return_stage=self.stage_id)
else:
self.task_id.reject_and_return(reason=self.reason)
return {"type": "ir.actions.act_window_close"} return {"type": "ir.actions.act_window_close"}

View File

@ -9,7 +9,8 @@
<field name="task_id" invisible="1"/> <field name="task_id" invisible="1"/>
<field name="available_stage_ids" invisible="1"/> <field name="available_stage_ids" invisible="1"/>
<field name="reason" placeholder="Enter the reason for rejection..."/> <field name="reason" placeholder="Enter the reason for rejection..."/>
<field name="stage_id" domain="[('id', 'in', available_stage_ids)]" options="{'no_create': True, 'no_open': True}"/> <field name="return_to_previous_stages" string="Return to Previous Stages"/>
<field name="stage_id" required="return_to_previous_stages" invisible="not return_to_previous_stages" domain="[('id', 'in', available_stage_ids)]" options="{'no_create': True, 'no_open': True}"/>
</group> </group>
<footer> <footer>
<button string="Reject" type="object" name="action_reject" class="btn-primary"/> <button string="Reject" type="object" name="action_reject" class="btn-primary"/>