From 5709ed9d3ae6c39e5d9441e459eab3d6091e8f47 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 21 Jan 2021 16:48:53 +0530 Subject: [PATCH 1/3] add method for allow timesheet user --- cor_custom/models/project.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cor_custom/models/project.py b/cor_custom/models/project.py index 5ccee2d..b92fc58 100755 --- a/cor_custom/models/project.py +++ b/cor_custom/models/project.py @@ -70,6 +70,29 @@ class Project(models.Model): project_cons_hrs = fields.One2many('project.consultant.hrs', 'project_id', 'Consultant Allocation', copy=False) comment = fields.Text(string='Comment') + # @api.onchange('allowed_internal_user_ids') + # def onchange_add_allowed_internal_users(self): + # user_list = [] + # consultant_list = [] + # employee_obj = [] + # if self.allowed_internal_user_ids: + # user_list = self.allowed_internal_user_ids.ids + # if self.sale_line_employee_ids: + # for consultant in self.sale_line_employee_ids: + # consultant_list.append(consultant.employee_id.user_id.id) + # print('44444444444', user_list) + # print('5555555555', consultant_list) + # users = (set(user_list)) - (set(consultant_list)) + # print('6666666666666666', users) + # for record in list(users): + # employee_obj = self.env['hr.employee'].search([('user_id', '=', record)]).ids + # if employee_obj: + # for employee in employee_obj: + # print('7777777777777', employee) + # self.sale_line_employee_ids.create({'project_id': self._origin.id, + # 'employee_id': employee}) + + def _onchange_calculate_timesheet_hours(self): self.consultant_timesheet_hrs = [(6, 0, False)] if self._origin.id: From 909e336beec925a847030d60dd417e426803fe3e Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 21 Jan 2021 17:26:12 +0530 Subject: [PATCH 2/3] add tag for project --- cor_custom/models/project.py | 12 +++++ cor_custom/security/ir.model.access.csv | 4 +- cor_custom/views/project_view.xml | 71 ++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/cor_custom/models/project.py b/cor_custom/models/project.py index b92fc58..179989a 100755 --- a/cor_custom/models/project.py +++ b/cor_custom/models/project.py @@ -69,6 +69,7 @@ class Project(models.Model): copy=False, help="Consultant timesheet hours") project_cons_hrs = fields.One2many('project.consultant.hrs', 'project_id', 'Consultant Allocation', copy=False) comment = fields.Text(string='Comment') + tag_ids = fields.Many2many('custom.project.tags', string='Tags') # @api.onchange('allowed_internal_user_ids') # def onchange_add_allowed_internal_users(self): @@ -286,3 +287,14 @@ class InheritProjectProductEmployeeMap(models.Model): else: # line.price_unit = 0 line.currency_id = False + +class CustomProjectTags(models.Model): + """ Tags of project's tasks """ + _name = "custom.project.tags" + _description = "Project Tag" + + name = fields.Char('Name', required=True) + + _sql_constraints = [ + ('name_uniq', 'unique (name)', "Tag name already exists!"), + ] \ No newline at end of file diff --git a/cor_custom/security/ir.model.access.csv b/cor_custom/security/ir.model.access.csv index 371580d..2e8fa3e 100755 --- a/cor_custom/security/ir.model.access.csv +++ b/cor_custom/security/ir.model.access.csv @@ -7,4 +7,6 @@ access_project_consultant_hrs_pmanager,project.consultant.hrs,model_project_cons access_model_project_multi_budget_assign_puser,project.multi.budget.assign,model_project_multi_budget_assign,project.group_project_user,1,0,0,0 access_model_project_multi_budget_assign_pmanager,project.multi.budget.assign,model_project_multi_budget_assign,project.group_project_manager,1,1,1,1 access_model_project_multi_budget_assign_line_puser,project.multi.budget.assign.line,model_project_multi_budget_assign_line,project.group_project_user,1,0,0,0 -access_model_project_multi_budget_assign_line_pmanager,project.multi.budget.assign.line,model_project_multi_budget_assign_line,project.group_project_manager,1,1,1,1 \ No newline at end of file +access_model_project_multi_budget_assign_line_pmanager,project.multi.budget.assign.line,model_project_multi_budget_assign_line,project.group_project_manager,1,1,1,1 + +access_custom_project_tags_puser,custom.project.tags,model_custom_project_tags,project.group_project_user,1,1,1,1 diff --git a/cor_custom/views/project_view.xml b/cor_custom/views/project_view.xml index 0f68c30..6f7e6ef 100755 --- a/cor_custom/views/project_view.xml +++ b/cor_custom/views/project_view.xml @@ -21,8 +21,9 @@ - - + + @@ -33,7 +34,10 @@ - + + + + @@ -60,9 +64,10 @@ widget="radio"/> - + - + @@ -107,7 +112,8 @@ domain="[('order_id','=',parent.sale_order_id), ('is_service', '=', True)]"/> --> - + @@ -190,6 +196,57 @@ + + + Tags + custom.project.tags + + + + + + + + + Tags + custom.project.tags + +
+ + + + + +
+
+
+ + + Tags + custom.project.tags + + + + + + + + + Project Tags + custom.project.tags + +

+ No tags found. Let's create one! +

+

+ Tags are perfect to categorize your tasks. +

+
+
+ + + action="project.action_view_all_task" sequence="52" + groups="base.group_no_one,project.group_project_user"/> From 12af53c558e70277f8457a12dd9f337c77e92419 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 21 Jan 2021 17:49:06 +0530 Subject: [PATCH 3/3] add allowed project user in consultant screen --- cor_custom/models/project.py | 40 +++++++++++++++++------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/cor_custom/models/project.py b/cor_custom/models/project.py index 179989a..392338f 100755 --- a/cor_custom/models/project.py +++ b/cor_custom/models/project.py @@ -71,27 +71,25 @@ class Project(models.Model): comment = fields.Text(string='Comment') tag_ids = fields.Many2many('custom.project.tags', string='Tags') - # @api.onchange('allowed_internal_user_ids') - # def onchange_add_allowed_internal_users(self): - # user_list = [] - # consultant_list = [] - # employee_obj = [] - # if self.allowed_internal_user_ids: - # user_list = self.allowed_internal_user_ids.ids - # if self.sale_line_employee_ids: - # for consultant in self.sale_line_employee_ids: - # consultant_list.append(consultant.employee_id.user_id.id) - # print('44444444444', user_list) - # print('5555555555', consultant_list) - # users = (set(user_list)) - (set(consultant_list)) - # print('6666666666666666', users) - # for record in list(users): - # employee_obj = self.env['hr.employee'].search([('user_id', '=', record)]).ids - # if employee_obj: - # for employee in employee_obj: - # print('7777777777777', employee) - # self.sale_line_employee_ids.create({'project_id': self._origin.id, - # 'employee_id': employee}) + @api.onchange('allowed_internal_user_ids') + def onchange_add_allowed_internal_users(self): + user_list = [] + consultant_list = [] + employee_obj = [] + if self.allowed_internal_user_ids: + user_list = self.allowed_internal_user_ids.ids + if self.sale_line_employee_ids: + for consultant in self.sale_line_employee_ids: + consultant_list.append(consultant.employee_id.user_id.id) + users = (set(user_list)) - (set(consultant_list)) + for record in list(users): + emp_obj = self.env['hr.employee'].search([('user_id', '=', record)]).id + if emp_obj: + employee_obj.append(emp_obj) + if employee_obj: + for employee in employee_obj: + self.sale_line_employee_ids.create({'project_id': self._origin.id, + 'employee_id': employee}) def _onchange_calculate_timesheet_hours(self):