Report code and unused menu hidden

This commit is contained in:
root 2022-08-28 17:31:36 +05:30
parent 288f87b93e
commit af0578a880
12 changed files with 311 additions and 33 deletions

View File

@ -54,6 +54,8 @@ class AccountAnalyticLine(models.Model):
sub_project = fields.Many2one('project.project', domain="[('is_sub_project', '=', True)]",
string='Sub Project')
active_project = fields.Boolean(related='project_id.active', store=True)
pricing_type = fields.Selection(related='project_id.pricing_type', store=True)
project_type= fields.Selection(related='project_id.project_type', store=True)
@api.onchange('project_id')
def _onchange_sub_project_id(self):

View File

@ -108,11 +108,11 @@
</field>
</record>
<menuitem name="View Allocation" id="menu_main_cor_consult_allocation"
<!--<menuitem name="View Allocation" id="menu_main_cor_consult_allocation"
action="cor_custom.action_project_consultant_hrs_report" sequence="53"
groups="base.group_no_one,project.group_project_user"/>
groups="base.group_no_one,project.group_project_user"/>-->
<record id="project_consul_hours_report_view_form" model="ir.ui.view">
<!--<record id="project_consul_hours_report_view_form" model="ir.ui.view">
<field name="name">Project Consul Report Hours</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
@ -125,6 +125,6 @@
</button>
</div>
</field>
</record>
</record>-->
</odoo>

View File

@ -163,7 +163,7 @@
<field name="date_start" groups="project.group_project_manager"/>
<field name="date" groups="project.group_project_manager"/>
</xpath>
<xpath expr="//page[@name='settings']" position="after">
<!-- <xpath expr="//page[@name='settings']" position="after">
<page string="Consultant Allocation" groups="project.group_project_manager"
attrs="{'invisible':['|',('pricing_type','!=','employee_rate'),('project_type','!=','hours_in_consultant')]}">
<field name="project_cons_hrs">
@ -179,7 +179,7 @@
</tree>
</field>
</page>
</xpath>
</xpath> -->
<xpath expr="//field[@name='privacy_visibility']" position="replace">
<field name="privacy_visibility" widget="radio" groups="project.group_project_manager"/>
</xpath>

View File

@ -36,7 +36,7 @@
</field>
</record>
<record id="action_multi_budget_assign" model="ir.actions.act_window">
<!-- <record id="action_multi_budget_assign" model="ir.actions.act_window">
<field name="name">Consultant Budget Hours Assign</field>
<field name="res_model">project.multi.budget.assign</field>
<field name="view_mode">form</field>
@ -44,7 +44,7 @@
<field name="target">new</field>
<field name="binding_model_id" ref="project.model_project_project"/>
<field name="binding_view_types">form</field>
</record>
</record>-->
</data>
</odoo>

View File

@ -16,13 +16,14 @@
'security/ir.model.access.csv',
'wizard/project_create_expenses_views.xml',
'views/assets.xml',
#'views/project_view.xml',
'views/project_view.xml',
'report/project_budget_hrs_analysis_views.xml',
'report/project_budget_amt_analysis_views.xml',
'report/project_timeline_report_views.xml',
'report/project_timesheet_report_views.xml',
'report/project_revenue_custom_report_views.xml',
'report/project_revenue_custom_report2_views.xml',
'report/project_revenue_custom_report3_views.xml',
'report/project_consultant_custom_report_views.xml',
#'report/cor_project_report_views.xml',
],

View File

@ -7,4 +7,15 @@ class Project(models.Model):
_inherit = 'project.project'
def action_view_allocation_custom_report3(self):
action = self.env["ir.actions.actions"]._for_xml_id("project_report.project_revenue_custom_report3_action")
action['context'] = {'search_default_project_id': self.id,
'search_default_project': 1,
'search_default_group_employee': 1,
'search_default_group_enddate': 1,
#'default_res_model': 'project.revenue.custom.report3'
}
return action

View File

@ -7,5 +7,6 @@ from . import project_timeline_report
from . import project_timesheet_report
from . import project_revenue_custom_report
from . import project_revenue_custom_report2
from . import project_revenue_custom_report3
from . import project_consultant_custom_report
#from . import cor_project_report

View File

@ -73,10 +73,10 @@
<field name="context">{'search_default_group_project': 1,'search_default_group_employee': 1}</field>
</record>
<menuitem id="menu_project_consultant_custom_report"
<!--<menuitem id="menu_project_consultant_custom_report"
parent="project.menu_project_report"
action="project_consultant_custom_report_action"
name="Consultant Allocation Reports"
sequence="51"/>
sequence="51"/>-->
</odoo>

View File

@ -55,44 +55,60 @@ with pro_tsheet as (SELECT
date_trunc('month', max(AAL.end_datetime::date)) AS max,
AAL.start_datetime::date as t_startdate,
AAL.end_datetime::date as t_enddate,
PRO.date_start as pro_sdate,
PRO.date as pro_edate,
PRO.id as pproject_id,
AAL.project_id as project_id,
PRO.active as project_active,
PRO.project_type,
PRO.pricing_type,
(select PRO.id from project_subproject_rel as PAR where PRO.id=PAR.project_id limit 1) as parent_project,
--CASE WHEN PRO.sub_project is not null then True else False END as is_sub_project,
PRO.is_sub_project,
AAL.sub_project as sub_project,
STRING_AGG(distinct tag_master.name, ', ') as tag_name,
PRO.partner_id AS partner_id,
AAL.id as timesheet_id,
PRO.budgeted_revenue as budgeted_revenue,
PRO.budgeted_hours2 as budgeted_hours,
PRO.expenses_amt,
pro.hourly_rate AS pro_hourly_rate,
AAL.employee_id,
AAL.unit_amount as unit_amount,
AAL.amount * -1 as actual_cost
FROM project_project PRO
(AAL.unit_amount * pro.hourly_rate) AS actual_revenue,
(AAL.amount * -1) as actual_cost
FROM project_project PRO
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
LEFT JOIN custom_project_tags_project_project_rel AS cus_pro_tag ON pro.id = cus_pro_tag.project_project_id
LEFT JOIN custom_project_tags as tag_master ON tag_master.id = cus_pro_tag.custom_project_tags_id
LEFT JOIN project_subproject_rel as sub_pro ON sub_pro.project_id = PRO.id
GROUP BY PRO.id, PRO.pricing_type, PRO.project_type, AAL.project_id, PRO.pricing_type, PRO.project_type,
PRO.is_sub_project, sub_pro.id,
AAL.id, AAL.employee_id, AAL.start_datetime::date, AAL.end_datetime::date, AAL.unit_amount, AAL.amount
GROUP BY PRO.id, AAL.start_datetime::date, AAL.end_datetime::date, AAL.project_id, PRO.active,
PRO.project_type, PRO.pricing_type, PRO.is_sub_project, AAL.sub_project, AAL.project_id,
PRO.partner_id, --sub_pro.id,
AAL.id, PRO.id, PRO.budgeted_revenue, PRO.budgeted_hours2, PRO.expenses_amt,
pro.hourly_rate, AAL.employee_id, AAL.unit_amount, AAL.amount
),
input_data as (SELECT generate_series(min, max,'1 month'):: date AS start_date,
(generate_series(min, max, '1 month'):: date + '1 month' :: interval - '1 day' :: interval):: date AS end_date,
project_id, employee_id
from pro_tsheet),
pro_tsheet.project_id, pro_tsheet.employee_id
from pro_tsheet),
cons_data as (
select PRO_EMP.start_date as cons_start_date, PRO_EMP.end_date as cons_end_date,
SELECT PRO_EMP.start_date as cons_start_date, PRO_EMP.end_date as cons_end_date,
sum(PRO_EMP.price_unit) as price_unit, PRO_EMP.project_id, PRO_EMP.employee_id,
sum(PRO_EMP.employee_price) as cons_price
from project_sale_line_employee_map PRO_EMP
sum(PRO_EMP.employee_price) as cons_price, sum(PRO_EMP.cost) AS cons_budgeted_revenue,
sum(PRO_EMP.budgeted_qty) AS cons_budgeted_hours
from project_sale_line_employee_map PRO_EMP
GROUP BY PRO_EMP.start_date, PRO_EMP.end_date, PRO_EMP.project_id, PRO_EMP.employee_id
),
invoice_date as (
SELECT
date,
project_id,
(SELECT id FROM hr_employee WHERE LOWER(name)=LOWER('Fixed amount') limit 1) as employee_id,
fixed_amount from project_revenue_lines),
fixed_rate as (
select
ROW_NUMBER() OVER() as id,
SELECT
input_data.start_date,
input_data.end_date,
input_data.project_id,
@ -112,12 +128,12 @@ fixed_rate as (
0 as budgeted_hours,
0 as overall_hourly_rate,
0 AS pro_hourly_rate,
pro_tsheet.unit_amount,
pro_tsheet.unit_amount,
((pro_tsheet.actual_cost)/NULLIF(pro_tsheet.unit_amount, 0)) as timesheet_cost,
0.0 AS actual_revenue,
pro_tsheet.actual_cost,
0.0 AS expenses_amt,
0.0 - pro_tsheet.actual_cost AS profit_amt,
(0.0 - pro_tsheet.actual_cost) AS profit_amt,
0.0 AS profit_per
from input_data
left join pro_tsheet on pro_tsheet.project_id = input_data.project_id and pro_tsheet.employee_id = input_data.employee_id
@ -139,8 +155,247 @@ fixed_rate as (
input_data.employee_id,
pro_tsheet.unit_amount,
pro_tsheet.actual_cost
)
select * from fixed_rate
),
cons_no_limit1 as (SELECT
coalesce(pro_tsheet.pro_sdate, pro_tsheet.t_startdate) as start_date,
coalesce(pro_tsheet.pro_edate, pro_tsheet.t_enddate) as end_date,
pro_tsheet.pproject_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
null::char as role,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
null::int AS timesheet_id,
null::int AS employee_id,
0 as overall_budgeted_revenue,
pro_tsheet.budgeted_revenue,
pro_tsheet.budgeted_hours,
0 as overall_hourly_rate,
0 as pro_hourly_rate,
0 as unit_amount,
0 as timesheet_cost,
0 AS actual_revenue,
0 AS actual_cost,
pro_tsheet.expenses_amt AS expenses_amt,
0 AS profit_amt,
0 AS profit_per
from input_data
left join pro_tsheet on pro_tsheet.project_id = input_data.project_id and pro_tsheet.employee_id = input_data.employee_id
and coalesce(pro_tsheet.pro_sdate, pro_tsheet.min) >= input_data.start_date and pro_tsheet.t_enddate <= coalesce(pro_tsheet.pro_edate, pro_tsheet.max)
WHERE pro_tsheet.pricing_type='employee_rate' and pro_tsheet.project_type='hours_no_limit'
group by
pro_tsheet.pro_sdate,
pro_tsheet.pro_edate,
pro_tsheet.t_startdate,
pro_tsheet.t_enddate,
pro_tsheet.pproject_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
pro_tsheet.budgeted_revenue,
pro_tsheet.budgeted_hours,
pro_tsheet.unit_amount,
pro_tsheet.pro_hourly_rate,
pro_tsheet.expenses_amt
),
cons_no_limit2 as (
SELECT
input_data.start_date,
input_data.end_date,
input_data.project_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
null::char as role,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
pro_tsheet.timesheet_id,
input_data.employee_id,
0 as overall_budgeted_revenue,
pro_tsheet.budgeted_revenue,
pro_tsheet.budgeted_hours,
0 as overall_hourly_rate,
pro_tsheet.pro_hourly_rate,
pro_tsheet.unit_amount,
((pro_tsheet.actual_cost)/NULLIF(pro_tsheet.unit_amount, 0)) as timesheet_cost,
pro_tsheet.actual_revenue AS actual_revenue,
pro_tsheet.actual_cost,
pro_tsheet.expenses_amt AS expenses_amt,
0 AS profit_amt,
0 AS profit_per
from input_data
left join pro_tsheet on pro_tsheet.project_id = input_data.project_id and pro_tsheet.employee_id = input_data.employee_id
and pro_tsheet.t_startdate >= input_data.start_date and pro_tsheet.t_enddate <= input_data.end_date
WHERE pro_tsheet.pricing_type='employee_rate' and pro_tsheet.project_type='hours_no_limit'
group by
input_data.start_date,
input_data.end_date,
input_data.project_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
pro_tsheet.timesheet_id,
input_data.employee_id,
pro_tsheet.budgeted_revenue,
pro_tsheet.budgeted_hours,
input_data.employee_id,
pro_tsheet.unit_amount,
pro_tsheet.pro_hourly_rate,
pro_tsheet.actual_cost,
pro_tsheet.actual_revenue,
pro_tsheet.actual_cost,
pro_tsheet.expenses_amt
),
hrs_in_cons as (
SELECT
input_data.start_date,
input_data.end_date,
input_data.project_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
null::char as role,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
pro_tsheet.timesheet_id,
input_data.employee_id,
0 as overall_budgeted_revenue,
coalesce(cons_data.cons_budgeted_revenue, 0) as budgeted_revenue,
coalesce(cons_data.cons_budgeted_hours, 0) as budgeted_hours,
0 as overall_hourly_rate,
pro_tsheet.pro_hourly_rate,
pro_tsheet.unit_amount,
COALESCE(cons_data.cons_price, (pro_tsheet.unit_amount * cons_data.cons_price), 0) as timesheet_cost,
COALESCE((pro_tsheet.unit_amount * cons_data.price_unit), 0) as actual_revenue,
COALESCE(pro_tsheet.actual_cost, cons_data.cons_price, 0) as actual_cost,
0 AS expenses_amt,
0 AS profit_amt,
0 AS profit_per
from input_data
left join pro_tsheet on pro_tsheet.project_id = input_data.project_id and pro_tsheet.employee_id = input_data.employee_id
and pro_tsheet.t_startdate >= input_data.start_date and pro_tsheet.t_enddate <= input_data.end_date
left join cons_data on cons_data.project_id = input_data.project_id and cons_data.employee_id = input_data.employee_id
and cons_data.cons_start_date >= input_data.start_date and cons_data.cons_end_date <= input_data.end_date
WHERE pro_tsheet.pricing_type='employee_rate' and pro_tsheet.project_type='hours_in_consultant'
--and budgeted_hours>0 and pro_tsheet.unit_amount > 0
group by
input_data.start_date,
input_data.end_date,
input_data.project_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
pro_tsheet.timesheet_id,
input_data.employee_id,
cons_data.cons_budgeted_revenue,
cons_data.cons_budgeted_hours,
input_data.employee_id,
pro_tsheet.unit_amount,
pro_tsheet.pro_hourly_rate,
cons_data.cons_price,
cons_data.price_unit,
pro_tsheet.actual_cost,
pro_tsheet.actual_revenue,
pro_tsheet.actual_cost,
pro_tsheet.expenses_amt
),
invoice_data as (SELECT
invoice_date.date as start_date,
invoice_date.date as end_date,
--null::int as timesheet_id,
invoice_date.project_id,
pro_tsheet.project_active,
pro_tsheet.project_type,
pro_tsheet.pricing_type,
pro_tsheet.parent_project,
pro_tsheet.is_sub_project,
pro_tsheet.sub_project,
null::char as role,
pro_tsheet.tag_name,
pro_tsheet.partner_id,
pro_tsheet.timesheet_id,
invoice_date.employee_id,
0 as overall_budgeted_revenue,
0 as budgeted_revenue,
pro_tsheet.budgeted_hours,
0 as overall_hourly_rate,
0 as pro_hourly_rate,
0 as unit_amount,
0 as timesheet_cost,
invoice_date.fixed_amount as actual_revenue,
0 as actual_cost,
0.0 AS expenses_amt,
0.0 AS profit_amt,
0.0 AS profit_per
from invoice_date
left join pro_tsheet on pro_tsheet.project_id = invoice_date.project_id and pro_tsheet.employee_id = invoice_date.employee_id
left join input_data on input_data.project_id = invoice_date.project_id and input_data.employee_id = invoice_date.employee_id
and invoice_date.date >= input_data.start_date and invoice_date.date <= input_data.end_date),
final_res as (
select * from fixed_rate
UNION
select * from cons_no_limit1
UNION
select * from cons_no_limit2
UNION
select * from hrs_in_cons
UNION
select * from invoice_data
)
SELECT
ROW_NUMBER() OVER() as id,
start_date,
end_date,
project_id,
project_active,
project_type,
pricing_type,
parent_project,
is_sub_project,
sub_project,
role,
tag_name,
partner_id,
timesheet_id,
employee_id,
overall_budgeted_revenue,
budgeted_revenue,
budgeted_hours,
overall_hourly_rate,
pro_hourly_rate,
unit_amount,
timesheet_cost,
actual_revenue,
actual_cost,
expenses_amt,
profit_amt,
profit_per
from final_res
)""" % (self._table,))
@api.model

View File

@ -77,17 +77,16 @@
<filter string="Active" name="active_project" domain="[('project_active','=',True)]"/>
<filter string="Archived" name="active_project" domain="[('project_active','=',False)]"/>
<filter string="Is Sub Project" name="subproject" domain="[('is_sub_project','=',True)]"/>
<filter string="Is Parent Project" name="subproject" domain="[('sub_project','=',False)]"/>
<filter string="Is Sub Project" name="issubproject" domain="[('sub_project','!=',False)]"/>
<filter string="Manager Role" name="manager_role" domain="[('role','=','Manager')]"/>
<filter string="Employee Role" name="employee_role" domain="[('role','=','Employee')]"/>
<group expand="1" string="Group By">
<filter string="Project" name="group_project" context="{'group_by':'project_id'}"/>
<filter string="Parent Project" name="group_parent_project" context="{'group_by':'parent_project'}"/>
<filter string="Sub Project" name="group_sub_project" context="{'group_by':'sub_project'}"/>
<filter string="Consultant" name="group_employee" context="{'group_by':'employee_id'}"/>
<filter string="End Date" name="group_enddate" domain="[]" context="{'group_by':'end_date:month'}"/>
<filter string="Role" name="group_role" domain="[]" context="{'group_by':'role'}"/>
<filter string="Tags" name="group_tags" context="{'group_by':'tag_name'}"/>
<filter string="Parent Project" name="group_parent_project" context="{'group_by':'parent_project'}"/>
<!--<filter string="Budgeted Hours" name="budgethrs"
domain="[('timesheet_sdatetime','=',False)]"/>
<filter string="Current Year" name="currentyear"
@ -103,7 +102,9 @@
<field name="res_model">project.revenue.custom.report3</field>
<field name="view_mode">pivot,tree,graph</field>
<field name="search_view_id" ref="project_revenue_custom_report3_view_search"/>
<field name="context">{}</field>
<field name="context">{'search_default_group_project': 1, 'search_default_group_employee': 1,
'search_default_group_enddate': 1}
</field>
</record>

View File

@ -15,5 +15,5 @@ access_project_consultant_custom_report_manager,project_consultant_custom_report
access_project_consultant_custom_report_user,project_consultant_custom_report_user,model_project_consultant_custom_report,project.group_project_user,1,0,0,0
access_project_revenue_custom_report2_manager,project_revenue_custom_report2_manager,model_project_revenue_custom_report2,project.group_project_manager,1,1,1,1
access_project_revenue_custom_report2_user,project_revenue_custom_report2_user,model_project_revenue_custom_report2,project.group_project_user,1,0,0,0
access_project_revenue_custom_report3,access_project_revenue_custom_report3,model_project_revenue_custom_report3,,1,1,1,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
15 access_project_consultant_custom_report_user project_consultant_custom_report_user model_project_consultant_custom_report project.group_project_user 1 0 0 0
16 access_project_revenue_custom_report2_manager project_revenue_custom_report2_manager model_project_revenue_custom_report2 project.group_project_manager 1 1 1 1
17 access_project_revenue_custom_report2_user project_revenue_custom_report2_user model_project_revenue_custom_report2 project.group_project_user 1 0 0 0
18 access_project_revenue_custom_report3 access_project_revenue_custom_report3 model_project_revenue_custom_report3 1 1 1 0
19

View File

@ -8,10 +8,17 @@
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<div name="button_box" position="inside">
<button class="oe_stat_button" type="object" name="action_view_allocation_custom_report3"
icon="fa-tasks"
attrs="{'invisible':['|',('pricing_type','!=','employee_rate'),('project_type','!=','hours_in_consultant')]}"
string="View Allocation" widget="statinfo">
</button>
</div>
<!--<div name="button_box" position="inside">
<button class="oe_stat_button" type="action" name="%(project_report.project_project_action_multi_create_project_expense)d" icon="fa-usd"
attrs="{'invisible': [('allow_billable','=',False)]}" string="Create Expense" widget="statinfo">
</button>
</div>
</div>-->
<!--<xpath expr="//field[@name='analytic_account_id']" position="after">
<field name="budgeted_hours" attrs="{'invisible': [('pricing_type','=','fixed_rate')], 'required': [('pricing_type','!=','fixed_rate')]}"/>
<field name="budgeted_revenue" attrs="{'invisible': [('pricing_type','=','fixed_rate')], 'required': [('pricing_type','!=','fixed_rate')]}"/>