Report parent project updated

This commit is contained in:
projectsodoo 2021-02-11 12:32:06 +05:30
parent d04d067310
commit cdaece4eb2
4 changed files with 24 additions and 25 deletions

View File

@ -13,8 +13,9 @@ class BudgetAmtAnalysis(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)
is_sub_project = fields.Boolean("Is Sub Project", readonly=True)
sub_project = fields.Many2one('project.project', string='Sub Project', readonly=True)
parent_project = fields.Many2one('project.project', string='Parent Project', readonly=True)
#is_sub_project = fields.Boolean("Is Sub Project", readonly=True)
#sub_project = fields.Many2one('project.project', string='Sub Project', readonly=True)
partner_id = fields.Many2one('res.partner', string='Client', readonly=True)
amount_type = fields.Char(string="Amount Type")
revenue = fields.Float("Revenue", digits=(16, 2), readonly=True, group_operator="sum")
@ -38,11 +39,10 @@ class BudgetAmtAnalysis(models.Model):
tools.drop_view_if_exists(self._cr, self._table)
self._cr.execute("""
CREATE OR REPLACE VIEW %s AS (
SELECT ROW_NUMBER() OVER() as id, project_id, is_sub_project, sub_project, start_date, end_date, timesheet_date, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from (
SELECT ROW_NUMBER() OVER() as id, project_id, parent_project, start_date, end_date, timesheet_date, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from (
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro.date_start AS start_date,
pro.date AS end_date,
pro.partner_id AS partner_id,
@ -58,8 +58,7 @@ class BudgetAmtAnalysis(models.Model):
union
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro.date_start AS start_date,
pro.date AS end_date,
pro.partner_id AS partner_id,
@ -78,8 +77,7 @@ class BudgetAmtAnalysis(models.Model):
union
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro.date_start AS start_date,
pro.date AS end_date,
pro.partner_id AS partner_id,
@ -95,8 +93,7 @@ class BudgetAmtAnalysis(models.Model):
union
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro.date_start AS start_date,
pro.date AS end_date,
pro.partner_id AS partner_id,
@ -119,8 +116,7 @@ class BudgetAmtAnalysis(models.Model):
union
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro.date_start AS start_date,
pro.date AS end_date,
pro.partner_id AS partner_id,
@ -141,8 +137,7 @@ class BudgetAmtAnalysis(models.Model):
union
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro.date_start AS start_date,
pro.date AS end_date,
pro.partner_id AS partner_id,

View File

@ -38,8 +38,7 @@
<field name="timesheet_date" optional="hide"/>
<field name="amount_type"/>
<field name="revenue"/>
<field name="is_sub_project" optional="hide"/>
<field name="sub_project" optional="hide"/>
<field name="parent_project" optional="hide"/>
</tree>
</field>
</record>
@ -60,7 +59,7 @@
<filter string="Fixed rate" name="fixed" domain="[('pricing_type','=','fixed_rate')]"/>
<filter string="Hours are budgeted according to a consultant" name="fixed" domain="[('project_type','=','hours_in_consultant')]"/>
<filter string="Total hours are budgeted without division to consultant" name="limit" domain="[('project_type','=','hours_no_limit')]"/>
<filter string="Sub Project" name="subproject" domain="[('is_sub_project','=',True)]"/>
<!--<filter string="Sub Project" name="subproject" domain="[('is_sub_project','=',True)]"/>-->
<group expand="1" string="Group By">
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
<filter string="Client" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>

View File

@ -13,8 +13,9 @@ 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)
is_sub_project = fields.Boolean("Is Sub Project", readonly=True)
sub_project = fields.Many2one('project.project', string='Sub Project', readonly=True)
parent_project = fields.Many2one('project.project', string='Parent Project', readonly=True)
#is_sub_project = fields.Boolean("Is Sub Project", readonly=True)
#sub_project = fields.Many2one('project.project', string='Sub Project', readonly=True)
start_date = fields.Date(string='Start Date', readonly=True)
end_date = fields.Date(string='End Date', readonly=True)
partner_id = fields.Many2one('res.partner', string='Client', readonly=True)
@ -48,8 +49,9 @@ class BudgetHrsAnalysis(models.Model):
SELECT
ROW_NUMBER() OVER() as id,
project_id,
is_sub_project,
sub_project,
parent_project,
--is_sub_project,
--sub_project,
date_start AS start_date,
date AS end_date,
timesheet_date,
@ -62,6 +64,7 @@ class BudgetHrsAnalysis(models.Model):
hours from (
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
pro_emp.employee_id AS employee_id,
'Budgeted Hours' as hours_type,
null::date AS timesheet_date,
@ -76,6 +79,7 @@ class BudgetHrsAnalysis(models.Model):
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
null::int AS employee_id,
'Budgeted Hours' as hours_type,
null::date AS timesheet_date,
@ -90,6 +94,7 @@ class BudgetHrsAnalysis(models.Model):
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
AAL.employee_id AS employee_id,
'Actual Hours' as hours_type,
AAL.date AS timesheet_date,
@ -105,6 +110,7 @@ class BudgetHrsAnalysis(models.Model):
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parent_project,
AAL.employee_id AS employee_id,
'Actual Hours' as hours_type,
AAL.date AS timesheet_date,

View File

@ -37,8 +37,7 @@
<field name="timesheet_date" optional="hide"/>
<field name="hours_type"/>
<field name="hours"/>
<field name="is_sub_project" optional="hide"/>
<field name="sub_project" optional="hide"/>
<field name="parent_project" optional="hide"/>
</tree>
</field>
</record>
@ -58,7 +57,7 @@
<filter string="Fixed rate" name="fixed" domain="[('pricing_type','=','fixed_rate')]"/>
<filter string="Hours are budgeted according to a consultant" name="cons" domain="[('project_type','=','hours_in_consultant')]"/>
<filter string="Total hours are budgeted without division to consultant" name="limit" domain="[('project_type','=','hours_no_limit')]"/>
<filter string="Sub Project" name="subproject" domain="[('is_sub_project','=',True)]"/>
<!--<filter string="Sub Project" name="subproject" domain="[('is_sub_project','=',True)]"/>-->
<group expand="1" string="Group By">
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
<filter string="Client" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>