Skip to Content
Menu
This question has been flagged
2 Replies
3301 Views

Hello all,

I want to show progressbar in project.project in Project (built in module) . I am successful in doing that. Now I want to calculate this progressbar on the base of Total task in a project and assigned task of that project to a particular user which is login. It should display percentage of total tasks and assigned task of project of login user.

Anyone can send me its function?

Thank you

 

Avatar
Discard
Best Answer

Hello Muhammad,

You use this code,
https://www.odoo.com/forum/help-1/question/progressbar-151657
project_progress = fields.Float(
compute='_compute_project_progress_by_user', string='Project Progress')

@api.multi
def _compute_project_progress_by_user(self):
for project in self:
total_assigned_task = len(project.task_ids.filtered(lambda task: task.user_id = self.env.user.id))
total_tasks = project.task_count
project.project_progress = (total_assigned_task * 100) / total_tasks


Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Discard
Best Answer

Hi,

You can get a total tasks under the project with this code, 

task_count = self.env['project.task'].search_count([('project_id', '=', project)]) 
#project should hold the id of the project

Then to get the assigned task count of project using 
assign_task = self.env['project.project'].search_count([('user_id', '!=', False),
 ('project_id', '=', project)])


Then you can make necessary mathematical calculations and display the progress. Also you can refer: Task Check List
hanks
Avatar
Discard