mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-24 13:12:01 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
from . import crm_phonecall_report
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
# Copyright 2004-2010 Tiny SPRL (<http://tiny.be>)
|
||||
# Copyright 2017 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from psycopg2.extensions import AsIs
|
||||
|
||||
from odoo import fields, models, tools
|
||||
|
||||
AVAILABLE_STATES = [
|
||||
("draft", "Draft"),
|
||||
("open", "Todo"),
|
||||
("cancel", "Cancelled"),
|
||||
("done", "Held"),
|
||||
("pending", "Pending"),
|
||||
]
|
||||
|
||||
|
||||
class CrmPhonecallReport(models.Model):
|
||||
"""Generate BI report based on phonecall."""
|
||||
|
||||
_name = "crm.phonecall.report"
|
||||
_description = "Phone calls by user"
|
||||
_auto = False
|
||||
|
||||
user_id = fields.Many2one(comodel_name="res.users", string="User", readonly=True)
|
||||
team_id = fields.Many2one(comodel_name="crm.team", string="Team", readonly=True)
|
||||
priority = fields.Selection(
|
||||
selection=[("0", "Low"), ("1", "Normal"), ("2", "High")]
|
||||
)
|
||||
nbr_cases = fields.Integer(string="# of Cases", readonly=True)
|
||||
state = fields.Selection(AVAILABLE_STATES, string="Status", readonly=True)
|
||||
create_date = fields.Datetime(readonly=True, index=True)
|
||||
delay_close = fields.Float(
|
||||
string="Delay to close",
|
||||
digits=(16, 2),
|
||||
readonly=True,
|
||||
group_operator="avg",
|
||||
help="Number of Days to close the case",
|
||||
)
|
||||
duration = fields.Float(digits=(16, 2), readonly=True, group_operator="avg")
|
||||
delay_open = fields.Float(
|
||||
string="Delay to open",
|
||||
digits=(16, 2),
|
||||
readonly=True,
|
||||
group_operator="avg",
|
||||
help="Number of Days to open the case",
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name="res.partner", string="Partner", readonly=True
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company", string="Company", readonly=True
|
||||
)
|
||||
opening_date = fields.Datetime(readonly=True, index=True)
|
||||
date_closed = fields.Datetime(string="Close Date", readonly=True, index=True)
|
||||
|
||||
def _select(self):
|
||||
select_str = """
|
||||
select
|
||||
id,
|
||||
c.date_open as opening_date,
|
||||
c.date_closed as date_closed,
|
||||
c.state,
|
||||
c.user_id,
|
||||
c.team_id,
|
||||
c.partner_id,
|
||||
c.duration,
|
||||
c.company_id,
|
||||
c.priority,
|
||||
1 as nbr_cases,
|
||||
c.create_date as create_date,
|
||||
extract(
|
||||
'epoch' from (
|
||||
c.date_closed-c.create_date))/(3600*24) as delay_close,
|
||||
extract(
|
||||
'epoch' from (
|
||||
c.date_open-c.create_date))/(3600*24) as delay_open
|
||||
"""
|
||||
return select_str
|
||||
|
||||
def _from(self):
|
||||
from_str = """
|
||||
from crm_phonecall c
|
||||
"""
|
||||
return from_str
|
||||
|
||||
def init(self):
|
||||
"""Initialize the report."""
|
||||
tools.drop_view_if_exists(self.env.cr, self._table)
|
||||
self.env.cr.execute(
|
||||
"""
|
||||
create or replace view %s as (
|
||||
%s
|
||||
%s
|
||||
)""",
|
||||
(AsIs(self._table), AsIs(self._select()), AsIs(self._from())),
|
||||
)
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="view_report_crm_phonecall_graph" model="ir.ui.view">
|
||||
<field name="name">crm.phonecall.report.graph</field>
|
||||
<field name="model">crm.phonecall.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph stacked="True" string="Phone calls">
|
||||
<field name="team_id" type="row" />
|
||||
<field interval="month" name="create_date" type="col" />
|
||||
<field name="nbr_cases" type="measure" />
|
||||
<field name="duration" type="measure" />
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_report_crm_phonecall_pivot" model="ir.ui.view">
|
||||
<field name="name">crm.phonecall.report.pivot</field>
|
||||
<field name="model">crm.phonecall.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot disable_linking="True" string="Phone calls">
|
||||
<field name="team_id" type="row" />
|
||||
<field interval="month" name="create_date" type="col" />
|
||||
<field name="nbr_cases" type="measure" />
|
||||
<field name="duration" type="measure" />
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
<record id="filter_crm_phonecall_sales_team" model="ir.filters">
|
||||
<field name="name">By Sales Team</field>
|
||||
<field name="model_id">crm.phonecall.report</field>
|
||||
<field name="domain">[('state','=','done')]</field>
|
||||
<field eval="False" name="user_id" />
|
||||
<field name="context">
|
||||
{'group_by': ['team_id'], 'measures': ['nbr_cases', 'duration']}
|
||||
</field>
|
||||
</record>
|
||||
<record id="filter_crm_phonecall_delay_to_close" model="ir.filters">
|
||||
<field name="name">Delay To Close</field>
|
||||
<field name="model_id">crm.phonecall.report</field>
|
||||
<field name="domain">[('state','=','done')]</field>
|
||||
<field eval="False" name="user_id" />
|
||||
<field name="context">
|
||||
{'group_by': ['team_id'], 'measures': ['delay_close']}
|
||||
</field>
|
||||
</record>
|
||||
<record id="filter_crm_phonecall_phone_call_to_do" model="ir.filters">
|
||||
<field name="name">Phone Calls To Do</field>
|
||||
<field name="model_id">crm.phonecall.report</field>
|
||||
<field name="domain">[('state','in',('draft','open'))]</field>
|
||||
<field eval="False" name="user_id" />
|
||||
<field name="context">
|
||||
{'group_by': ['team_id'], 'measures': ['nbr_cases']}
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_report_crm_phonecall_filter" model="ir.ui.view">
|
||||
<field name="name">crm.phonecall.report.select</field>
|
||||
<field name="model">crm.phonecall.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search">
|
||||
<filter
|
||||
domain="[('state','in',('draft','open'))]"
|
||||
help="Phone calls which are in draft and open state"
|
||||
name="todo"
|
||||
string="Todo"
|
||||
/>
|
||||
<filter
|
||||
domain="[('state','=','done')]"
|
||||
help="Phone calls which are in closed state"
|
||||
name="held"
|
||||
string="Held"
|
||||
/>
|
||||
<filter
|
||||
domain="[('state','=','pending')]"
|
||||
help="Phone calls which are in pending state"
|
||||
name="not_held"
|
||||
string="Not Held"
|
||||
/>
|
||||
<separator />
|
||||
<filter
|
||||
context="{'invisible_section': False}"
|
||||
domain="[('team_id.user_id','=',uid)]"
|
||||
groups="sales_team.group_sale_manager"
|
||||
help="Phone calls that are assigned to one of the sale teams I manage"
|
||||
name="my_sales_team"
|
||||
string="My Sales Team(s)"
|
||||
/>
|
||||
<separator />
|
||||
<filter
|
||||
domain="[('user_id','=',uid)]"
|
||||
help="Phone Calls that are assigned to me"
|
||||
name="my_phone_calls"
|
||||
string="My Phone Calls"
|
||||
/>
|
||||
<field
|
||||
context="{'invisible_section': False}"
|
||||
groups="sales_team.group_sale_manager"
|
||||
name="team_id"
|
||||
string="Sales Team"
|
||||
/>
|
||||
<field name="user_id" string="Salesperson" />
|
||||
<group expand="0" string="Extended Filters...">
|
||||
<field
|
||||
filter_domain="[('partner_id','child_of',self)]"
|
||||
name="partner_id"
|
||||
/>
|
||||
<field groups="base.group_multi_company" name="company_id" />
|
||||
<field name="opening_date" />
|
||||
<field name="date_closed" />
|
||||
</group>
|
||||
<group expand="1" string="Group By">
|
||||
<filter
|
||||
context="{'group_by':'user_id'}"
|
||||
name="Salesperson"
|
||||
string="Salesperson"
|
||||
/>
|
||||
<filter
|
||||
context="{'group_by':'team_id'}"
|
||||
groups="sales_team.group_sale_manager"
|
||||
name="sales_team"
|
||||
string="Sales Team"
|
||||
/>
|
||||
<filter
|
||||
context="{'group_by':'partner_id'}"
|
||||
name="customer"
|
||||
string="Customer"
|
||||
/>
|
||||
<filter
|
||||
context="{'group_by':'state'}"
|
||||
name="status"
|
||||
string="Status"
|
||||
/>
|
||||
<separator />
|
||||
<filter
|
||||
context="{'group_by':'create_date:month'}"
|
||||
help="Month of call"
|
||||
name="creation_month"
|
||||
string="Creation Month"
|
||||
/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="crm_phonecall_report_action" model="ir.actions.act_window">
|
||||
<field name="name">Phone Calls Analysis</field>
|
||||
<field name="res_model">crm.phonecall.report</field>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
</record>
|
||||
<record id="crm_phonecall_report_action_team" model="ir.actions.act_window">
|
||||
<field name="name">Phone Calls Analysis</field>
|
||||
<field name="res_model">crm.phonecall.report</field>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
<field name="context">{'search_default_team_id': active_id}</field>
|
||||
</record>
|
||||
<menuitem
|
||||
action="crm_phonecall_report_action"
|
||||
groups="sales_team.group_sale_salesman"
|
||||
id="menu_report_crm_phonecalls_tree"
|
||||
name="Phone Calls Analysis"
|
||||
parent="crm.crm_menu_report"
|
||||
sequence="15"
|
||||
/>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue