Report filter by options added

This commit is contained in:
projectsodoo 2021-01-11 17:40:46 +05:30
parent 806b1b8ad1
commit bf4c336206
4 changed files with 28 additions and 4 deletions

View File

@ -16,6 +16,14 @@ class BudgetAmtAnalysis(models.Model):
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")
project_type = fields.Selection([
('hours_in_consultant', 'Hours are budgeted according to a consultant'),
('hours_no_limit', 'Total hours are budgeted without division to consultant'),
], string="Project Type", readonly=True)
pricing_type = fields.Selection([
('fixed_rate', 'Fixed rate'),
('employee_rate', 'Consultant rate')
], string="Pricing", readonly=True)
#employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True)
#budgeted_revenue = fields.Float("Budgeted Revenue", digits=(16, 2), readonly=True, group_operator="sum")
#actual_revenue = fields.Float("Actual Revenue", digits=(16, 2), readonly=True, group_operator="sum")
@ -25,19 +33,21 @@ 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, partner_id, amount_type, revenue from (
SELECT ROW_NUMBER() OVER() as id, project_id, partner_id, amount_type, pricing_type, project_type, revenue from (
SELECT
row_number() OVER() AS id,
PRO.id AS project_id,
PRO.create_date AS create_date,
PRO.partner_id AS partner_id,
'Budgeted Revenue' as amount_type,
PRO.pricing_type as pricing_type,
PRO.project_type as project_type,
PRO.budgeted_revenue 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
--LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
WHERE PRO.active = 't' and PRO.pricing_type!='fixed_rate'
WHERE PRO.active = 't'
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total
union
SELECT
@ -46,12 +56,14 @@ class BudgetAmtAnalysis(models.Model):
PRO.create_date AS create_date,
PRO.partner_id AS partner_id,
'Actual Revenue' as amount_type,
PRO.pricing_type as pricing_type,
PRO.project_type as project_type,
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
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
WHERE PRO.active = 't' and PRO.pricing_type!='fixed_rate'
WHERE PRO.active = 't'
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total
order by create_date desc, project_id, amount_type desc) as res
)""" % (self._table,))

View File

@ -35,6 +35,9 @@
<field name="project_id"/>
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
<!--<field name="employee_id"/>-->
<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="Fixed rate" name="fixed" domain="[('pricing_type','=','fixed_rate')]"/>
<group expand="1" string="Group By">
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
<filter string="Customer" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>

View File

@ -17,6 +17,10 @@ class BudgetHrsAnalysis(models.Model):
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")
project_type = fields.Selection([
('hours_in_consultant', 'Hours are budgeted according to a consultant'),
('hours_no_limit', 'Total hours are budgeted without division to consultant'),
], string="Project Type", readonly=True)
#budgeted_hours = fields.Float("Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum")
#actual_hours = fields.Float("Actual Hours", digits=(16, 2), readonly=True, group_operator="sum")
@ -26,13 +30,14 @@ class BudgetHrsAnalysis(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, partner_id, employee_id, hours_type, hours from (
SELECT ROW_NUMBER() OVER() as id, project_id, partner_id, employee_id, hours_type, project_type, hours from (
SELECT
PRO.id AS project_id,
PRO.create_date AS create_date,
PRO.partner_id AS partner_id,
null AS employee_id,
'Budgeted Hours' as hours_type,
PRO.project_type as project_type,
PRO.budgeted_hours AS hours
FROM
project_project PRO
@ -50,6 +55,7 @@ class BudgetHrsAnalysis(models.Model):
PRO.partner_id AS partner_id,
Pro_emp.employee_id AS employee_id,
'Budgeted Hours' as hours_type,
PRO.project_type as project_type,
Pro_emp.budgeted_qty as hours
FROM
project_project PRO
@ -68,6 +74,7 @@ class BudgetHrsAnalysis(models.Model):
PRO.partner_id AS partner_id,
AAL.employee_id AS employee_id,
'Actual Hours' as hours_type,
PRO.project_type as project_type,
AAL.unit_amount AS hours
FROM
project_project PRO

View File

@ -34,6 +34,8 @@
<field name="project_id"/>
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
<field name="employee_id"/>
<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')]"/>
<group expand="1" string="Group By">
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
<filter string="Customer" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>