From b1514685911f037e05cef3d077e1d8aec18efe47 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Wed, 6 Jan 2021 21:11:19 +0530 Subject: [PATCH 1/2] Report and forecast updated --- project_forecast/models/project_forecast.py | 15 ++++++++++++++- project_forecast/views/planning_views.xml | 4 +++- .../report/project_budget_amt_analysis.py | 2 +- .../report/project_budget_amt_analysis_views.xml | 2 +- .../report/project_budget_hrs_analysis.py | 2 +- .../report/project_budget_hrs_analysis_views.xml | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/project_forecast/models/project_forecast.py b/project_forecast/models/project_forecast.py index 824e4f1..d1071cc 100755 --- a/project_forecast/models/project_forecast.py +++ b/project_forecast/models/project_forecast.py @@ -17,6 +17,7 @@ class PlanningShift(models.Model): project_id = fields.Many2one('project.project', string="Project", domain="[('company_id', '=', company_id), ('allow_forecast', '=', True)]", check_company=True) budgeted_hours = fields.Float("Budgeted hours", default=0, compute='_compute_budgeted_hours', store=True) + rem_all_hours = fields.Float("Remaining Allocated hours", default=0, compute='_compute_budgeted_hours', store=True) task_id = fields.Many2one('project.task', string="Task", domain="[('company_id', '=', company_id), ('project_id', '=', project_id)]", check_company=True) _sql_constraints = [ @@ -27,6 +28,8 @@ class PlanningShift(models.Model): def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True): if 'budgeted_hours' in fields: fields.remove('budgeted_hours') + if 'rem_all_hours' in fields: + fields.remove('rem_all_hours') return super(PlanningShift, self).read_group(domain, fields, groupby, offset, limit, orderby, lazy) @@ -36,12 +39,22 @@ class PlanningShift(models.Model): if slot.project_id and slot.employee_id: if slot.project_id.project_type == 'hours_no_limit': slot.budgeted_hours = slot.project_id.budgeted_hours - #print("slot.project_id.project_type", slot.project_id.project_type) + rec = self.search([('project_id','=',slot.project_id.id)]) + all_hours = 0 + for r in rec: + all_hours += r.allocated_hours + slot.rem_all_hours = self.budgeted_hours - all_hours if slot.project_id.project_type == 'hours_in_consultant': cons = self.env['project.sale.line.employee.map'].search([('employee_id','=',slot.employee_id.id),('project_id','=',slot.project_id.id)], limit=1) slot.budgeted_hours = cons and cons.budgeted_qty or 0 + rec = self.search([('employee_id', '=', slot.employee_id.id),('project_id', '=', slot.project_id.id)]) + all_hours = 0 + for r in rec: + all_hours += r.allocated_hours + slot.rem_all_hours = self.budgeted_hours - all_hours else: slot.budgeted_hours = 0 + slot.rem_all_hours = 0 @api.onchange('task_id') def _onchange_task_id(self): diff --git a/project_forecast/views/planning_views.xml b/project_forecast/views/planning_views.xml index b7dd760..d63574a 100755 --- a/project_forecast/views/planning_views.xml +++ b/project_forecast/views/planning_views.xml @@ -11,8 +11,9 @@ - + + @@ -28,6 +29,7 @@ + diff --git a/project_report/report/project_budget_amt_analysis.py b/project_report/report/project_budget_amt_analysis.py index 898478f..a71caa4 100755 --- a/project_report/report/project_budget_amt_analysis.py +++ b/project_report/report/project_budget_amt_analysis.py @@ -46,7 +46,7 @@ class BudgetAmtAnalysis(models.Model): PRO.create_date AS create_date, PRO.partner_id AS partner_id, 'Actual Revenue' as amount_type, - sum(AAL.amount * -1) + pro.total_expenses AS revenue + pro.total_expenses AS revenue FROM project_project PRO LEFT JOIN sale_order SO ON PRO.sale_order_id = SO.id LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id diff --git a/project_report/report/project_budget_amt_analysis_views.xml b/project_report/report/project_budget_amt_analysis_views.xml index c5bde16..2374ae0 100755 --- a/project_report/report/project_budget_amt_analysis_views.xml +++ b/project_report/report/project_budget_amt_analysis_views.xml @@ -48,7 +48,7 @@ Projects Revenue Acutal Vs Budget project.budget.amt.report - pivot,graph + graph,pivot {'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1} diff --git a/project_report/report/project_budget_hrs_analysis.py b/project_report/report/project_budget_hrs_analysis.py index a7fe224..4ca619d 100755 --- a/project_report/report/project_budget_hrs_analysis.py +++ b/project_report/report/project_budget_hrs_analysis.py @@ -14,7 +14,7 @@ class BudgetHrsAnalysis(models.Model): #analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', readonly=True) project_id = fields.Many2one('project.project', string='Project', readonly=True) partner_id = fields.Many2one('res.partner', string='Client', readonly=True) - employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True) + employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) hours_type = fields.Char(string="Hours Type", readonly=True) hours = fields.Float("Hours", digits=(16, 2), readonly=True, group_operator="sum") diff --git a/project_report/report/project_budget_hrs_analysis_views.xml b/project_report/report/project_budget_hrs_analysis_views.xml index 5b90433..23ee61b 100755 --- a/project_report/report/project_budget_hrs_analysis_views.xml +++ b/project_report/report/project_budget_hrs_analysis_views.xml @@ -48,7 +48,7 @@ Projects Hours Acutal Vs Budget project.budget.hrs.report - pivot,graph + graph,pivot {'search_default_group_by_project': 1,'search_default_group_by_hours_type': 1} From cdf16a972bb17864a08c1a93c171c6226a8de286 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Wed, 6 Jan 2021 21:46:40 +0530 Subject: [PATCH 2/2] Rem allocated updated --- project_forecast/models/project_forecast.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project_forecast/models/project_forecast.py b/project_forecast/models/project_forecast.py index d1071cc..c7ef3c0 100755 --- a/project_forecast/models/project_forecast.py +++ b/project_forecast/models/project_forecast.py @@ -39,19 +39,19 @@ class PlanningShift(models.Model): if slot.project_id and slot.employee_id: if slot.project_id.project_type == 'hours_no_limit': slot.budgeted_hours = slot.project_id.budgeted_hours - rec = self.search([('project_id','=',slot.project_id.id)]) + rec = slot.search([('project_id','=',slot.project_id.id)]) all_hours = 0 for r in rec: all_hours += r.allocated_hours - slot.rem_all_hours = self.budgeted_hours - all_hours + slot.rem_all_hours = slot.budgeted_hours - all_hours if slot.project_id.project_type == 'hours_in_consultant': cons = self.env['project.sale.line.employee.map'].search([('employee_id','=',slot.employee_id.id),('project_id','=',slot.project_id.id)], limit=1) slot.budgeted_hours = cons and cons.budgeted_qty or 0 - rec = self.search([('employee_id', '=', slot.employee_id.id),('project_id', '=', slot.project_id.id)]) + rec = slot.search([('employee_id', '=', slot.employee_id.id),('project_id', '=', slot.project_id.id)]) all_hours = 0 for r in rec: all_hours += r.allocated_hours - slot.rem_all_hours = self.budgeted_hours - all_hours + slot.rem_all_hours = slot.budgeted_hours - all_hours else: slot.budgeted_hours = 0 slot.rem_all_hours = 0