diff --git a/addons/crm_project/report/report_crm_project_bug.py b/addons/crm_project/report/report_crm_project_bug.py index 25ef06db7cd..51a589a46fb 100644 --- a/addons/crm_project/report/report_crm_project_bug.py +++ b/addons/crm_project/report/report_crm_project_bug.py @@ -1,12 +1,14 @@ from osv import fields,osv import tools -class report_crm_project_bug_user(osv.osv): - _name = "report.crm.project.bug.user" +class report_crm_project_bug(osv.osv): + _name = "report.crm.project.bug" _description = "Project Bug by user and section" _auto = False - _inherit = "report.crm.case.user" + _inherit = "report.crm.case" _columns = { + 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.project.bug')]"), + 'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'crm.project.bug')]"), 'probability': fields.float('Avg. Probability', readonly=True), 'amount_revenue': fields.float('Est.Revenue', readonly=True), 'amount_costs': fields.float('Est.Cost', readonly=True), @@ -14,9 +16,9 @@ class report_crm_project_bug_user(osv.osv): 'delay_close': fields.char('Delay to close', size=20, readonly=True), } def init(self, cr): - tools.drop_view_if_exists(cr, 'report_crm_project_bug_user') + tools.drop_view_if_exists(cr, 'report_crm_project_bug') cr.execute(""" - create or replace view report_crm_project_bug_user as ( + create or replace view report_crm_project_bug as ( select min(c.id) as id, to_char(c.create_date, 'YYYY') as name, @@ -24,43 +26,8 @@ class report_crm_project_bug_user(osv.osv): c.state, c.user_id, c.section_id, - count(*) as nbr, - sum(planned_revenue) as amount_revenue, - sum(planned_cost) as amount_costs, - sum(planned_revenue*probability)::decimal(16,2) as amount_revenue_prob, - avg(probability)::decimal(16,2) as probability, - to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close - from - crm_project_bug c - group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id - )""") -report_crm_project_bug_user() - -class report_crm_project_bug_categ(osv.osv): - _name = "report.crm.project.bug.categ" - _description = "Project Bug by section and category" - _auto = False - _inherit = "report.crm.case.categ" - _columns = { - 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.project.bug')]"), - 'amount_revenue': fields.float('Est.Revenue', readonly=True), - 'amount_costs': fields.float('Est.Cost', readonly=True), - 'amount_revenue_prob': fields.float('Est. Rev*Prob.', readonly=True), - 'probability': fields.float('Avg. Probability', readonly=True), - 'delay_close': fields.char('Delay Close', size=20, readonly=True), - } - - def init(self, cr): - tools.drop_view_if_exists(cr, 'report_crm_project_bug_categ') - cr.execute(""" - create or replace view report_crm_project_bug_categ as ( - select - min(c.id) as id, - to_char(c.create_date, 'YYYY') as name, - to_char(c.create_date, 'MM') as month, c.categ_id, - c.state, - c.section_id, + c.stage_id, count(*) as nbr, sum(planned_revenue) as amount_revenue, sum(planned_cost) as amount_costs, @@ -69,63 +36,9 @@ class report_crm_project_bug_categ(osv.osv): to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close from crm_project_bug c - group by c.categ_id,to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state,c.section_id + group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.categ_id,c.stage_id )""") -report_crm_project_bug_categ() +report_crm_project_bug() -class report_crm_project_bug_section(osv.osv): - _name = "report.crm.project.bug.section" - _description = "Project bug by Section" - _auto = False - _inherit = "report.crm.case.section" - - def _get_data(self, cr, uid, ids, field_name, arg, context={}): - res = {} - state_perc = 0.0 - avg_ans = 0.0 - - for case in self.browse(cr, uid, ids, context): - if field_name != 'avg_answers': - state = field_name[5:] - cr.execute("select count(*) from crm_project_bug where section_id =%s and state='%s'"%(case.section_id.id,state)) - state_cases = cr.fetchone()[0] - perc_state = (state_cases / float(case.nbr_cases) ) * 100 - - res[case.id] = perc_state - else: - cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id)) - logs = cr.fetchone()[0] - - avg_ans = logs / case.nbr_cases - res[case.id] = avg_ans - - return res - - _columns = { - 'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"), - 'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"), - 'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"), - 'delay_close': fields.char('Delay to close', size=20, readonly=True), - } - _order = 'name desc, section_id' - def init(self, cr): - tools.drop_view_if_exists(cr, 'report_crm_project_bug_section') - cr.execute(""" - create or replace view report_crm_project_bug_section as ( - select - min(c.id) as id, - to_char(c.create_date, 'YYYY') as name, - to_char(c.create_date, 'MM') as month, - count(*) as nbr_cases, - c.section_id as section_id, - 0 as avg_answers, - 0.0 as perc_done, - 0.0 as perc_cancel, - to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close - from - crm_project_bug c - group by to_char(c.create_date, 'YYYY'),to_char(c.create_date, 'MM'),c.section_id - )""") -report_crm_project_bug_section() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/crm_project/report_crm_project_bug_view.xml b/addons/crm_project/report_crm_project_bug_view.xml index 4c6ea353ec7..e822d4a7f0a 100644 --- a/addons/crm_project/report_crm_project_bug_view.xml +++ b/addons/crm_project/report_crm_project_bug_view.xml @@ -2,28 +2,32 @@ - - report.crm.project.bug.user.tree - report.crm.project.bug.user - + + report.crm.project.bug.tree + report.crm.project.bug tree - - + + + + - - - + + + + + + - - report.crm.project.bug.user.form - report.crm.project.bug.user - + + report.crm.project.bug.form + report.crm.project.bug + form @@ -36,12 +40,12 @@ - - report.crm.project.bug.user.graph - report.crm.project.bug.user + + report.crm.project.bug.graph + report.crm.project.bug graph - + @@ -49,10 +53,10 @@ - - report.crm.project.bug.user.select - report.crm.project.bug.user - + + report.crm.project.bug.select + report.crm.project.bug + search @@ -60,134 +64,30 @@ - - Project Bug by User and Section - report.crm.project.bug.user + + Project Bug + report.crm.project.bug form graph,tree - - + + + + + + + tree + + + + + + graph + + + - - - - - - - - report.crm.project.bug.categ.tree - report.crm.project.bug.categ - - tree - - - - - - - - - - - - report.crm.project.bug.categ.form - report.crm.project.bug.categ - - form - - - - - - - - - - - - - report.crm.project.bug.categ.graph - report.crm.project.bug.categ - graph - - - - - - - - - - - report.crm.project.bug.categ.select - report.crm.project.bug.categ - - search - - - - - - - - Project Bugs by Categories and Section - report.crm.project.bug.categ - form - graph,tree - - - - - - - - - report.crm.project.bug.section.tree - report.crm.project.bug.section - - tree - - - - - - - - - - - - report.crm.project.bug.section.graph - report.crm.project.bug.section - graph - - - - - - - - - - report.crm.project.bug.section.select - report.crm.project.bug.section - - search - - - - - - - - Project Bugs by Section - report.crm.project.bug.section - form - graph,tree - - - - + + diff --git a/addons/crm_project/security/ir.model.access.csv b/addons/crm_project/security/ir.model.access.csv index a29e29c027b..e483f2ccc20 100644 --- a/addons/crm_project/security/ir.model.access.csv +++ b/addons/crm_project/security/ir.model.access.csv @@ -1,5 +1,3 @@ "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "access_crm_project_bug","crm.project.bug","model_crm_project_bug","crm.group_crm_manager",1,1,1,1 -"access_report_crm_project_bug_user","report.crm.project.bug.user","model_report_crm_project_bug_user","crm.group_crm_manager",1,0,0,0 -"access_report_crm_project_bug_categ","report.crm.project.bug.categ","model_report_crm_project_bug_categ","crm.group_crm_manager",1,0,0,0 -"access_repor_crm_project_bug_section","report.crm.project.bug.section","model_report_crm_project_bug_section","crm.group_crm_manager",1,0,0,0 +"access_report_crm_project_bug","report.crm.project.bug","model_report_crm_project_bug","crm.group_crm_manager",1,0,0,0 diff --git a/addons/report_crm/report_crm_claim_view.xml b/addons/report_crm/report_crm_claim_view.xml index 54431019b9e..396b2131b5d 100644 --- a/addons/report_crm/report_crm_claim_view.xml +++ b/addons/report_crm/report_crm_claim_view.xml @@ -11,10 +11,11 @@ - - + + + @@ -86,7 +87,7 @@ - + diff --git a/addons/report_crm/report_crm_fundraising_view.xml b/addons/report_crm/report_crm_fundraising_view.xml index 8e8d54169ee..8faba79a093 100644 --- a/addons/report_crm/report_crm_fundraising_view.xml +++ b/addons/report_crm/report_crm_fundraising_view.xml @@ -89,7 +89,7 @@ - + diff --git a/addons/report_crm/report_crm_lead_view.xml b/addons/report_crm/report_crm_lead_view.xml index 7ed80abbde5..a8ae77672f4 100644 --- a/addons/report_crm/report_crm_lead_view.xml +++ b/addons/report_crm/report_crm_lead_view.xml @@ -55,9 +55,7 @@ search - - @@ -69,6 +67,7 @@ graph,tree + @@ -84,6 +83,7 @@ - + + diff --git a/addons/report_crm/report_crm_opportunity_view.xml b/addons/report_crm/report_crm_opportunity_view.xml index 6b4f7dbc4b0..4efbba6ef00 100644 --- a/addons/report_crm/report_crm_opportunity_view.xml +++ b/addons/report_crm/report_crm_opportunity_view.xml @@ -14,11 +14,12 @@ - - - + + + + @@ -66,7 +67,7 @@ - Opportunity + Opportunities report.crm.opportunity form graph,tree @@ -85,6 +86,7 @@ - + + diff --git a/addons/report_crm/report_crm_phonecall_view.xml b/addons/report_crm/report_crm_phonecall_view.xml index 9677e08395d..c7bb87f3dc4 100644 --- a/addons/report_crm/report_crm_phonecall_view.xml +++ b/addons/report_crm/report_crm_phonecall_view.xml @@ -82,7 +82,7 @@ - Phone calls + Phone Calls report.crm.phonecall form graph,tree @@ -104,7 +104,7 @@ - + diff --git a/addons/report_crm/report_crm_view.xml b/addons/report_crm/report_crm_view.xml index 33e855beea7..6e93f65fb43 100644 --- a/addons/report_crm/report_crm_view.xml +++ b/addons/report_crm/report_crm_view.xml @@ -57,6 +57,7 @@ + @@ -81,8 +82,7 @@ - - +