mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-23 20:12:05 +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,4 @@
|
|||
# Copyright 2015-2017 Odoo S.A.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||
|
||||
from . import crm_claim_report
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
# Copyright 2015-2017 Odoo S.A.
|
||||
# Copyright 2017 Tecnativa - Vicent Cubells
|
||||
# Copyright 2018 Tecnativa - Cristina Martin R.
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||
|
||||
from psycopg2.extensions import AsIs
|
||||
|
||||
from odoo import fields, models, tools
|
||||
|
||||
|
||||
class CrmClaimReport(models.Model):
|
||||
"""CRM Claim Report"""
|
||||
|
||||
_name = "crm.claim.report"
|
||||
_auto = False
|
||||
_description = "CRM Claim Report"
|
||||
|
||||
user_id = fields.Many2one(comodel_name="res.users", string="User", readonly=True)
|
||||
team_id = fields.Many2one(comodel_name="crm.team", string="Team", readonly=True)
|
||||
nbr_claims = fields.Integer(string="# of Claims", readonly=True)
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company", string="Company", readonly=True
|
||||
)
|
||||
create_date = fields.Datetime(readonly=True, index=True)
|
||||
claim_date = fields.Datetime(readonly=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",
|
||||
)
|
||||
stage_id = fields.Many2one(
|
||||
comodel_name="crm.claim.stage",
|
||||
string="Stage",
|
||||
readonly=True,
|
||||
domain="[('team_ids','=',team_id)]",
|
||||
)
|
||||
categ_id = fields.Many2one(
|
||||
comodel_name="crm.claim.category", string="Category", readonly=True
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name="res.partner", string="Partner", readonly=True
|
||||
)
|
||||
priority = fields.Selection(
|
||||
selection=[("0", "Low"), ("1", "Normal"), ("2", "High")]
|
||||
)
|
||||
type_action = fields.Selection(
|
||||
selection=[
|
||||
("correction", "Corrective Action"),
|
||||
("prevention", "Preventive Action"),
|
||||
],
|
||||
string="Action Type",
|
||||
)
|
||||
date_closed = fields.Datetime(string="Close Date", readonly=True, index=True)
|
||||
date_deadline = fields.Date(string="Deadline", readonly=True, index=True)
|
||||
delay_expected = fields.Float(
|
||||
string="Overpassed Deadline",
|
||||
digits=(16, 2),
|
||||
readonly=True,
|
||||
group_operator="avg",
|
||||
)
|
||||
email = fields.Integer(string="# Emails", readonly=True)
|
||||
subject = fields.Char(string="Claim Subject", readonly=True)
|
||||
|
||||
def _select(self):
|
||||
select_str = """
|
||||
SELECT
|
||||
min(c.id) AS id,
|
||||
c.date AS claim_date,
|
||||
c.date_closed AS date_closed,
|
||||
c.date_deadline AS date_deadline,
|
||||
c.user_id,
|
||||
c.stage_id,
|
||||
c.team_id,
|
||||
c.partner_id,
|
||||
c.company_id,
|
||||
c.categ_id,
|
||||
c.name AS subject,
|
||||
count(*) AS nbr_claims,
|
||||
c.priority AS priority,
|
||||
c.type_action AS type_action,
|
||||
c.create_date AS create_date,
|
||||
avg(extract(
|
||||
'epoch' FROM (
|
||||
c.date_closed-c.create_date)))/(3600*24)
|
||||
AS delay_close,
|
||||
(
|
||||
SELECT count(id)
|
||||
FROM mail_message
|
||||
WHERE model='crm.claim'
|
||||
AND res_id=c.id) AS email,
|
||||
extract(
|
||||
'epoch' FROM (
|
||||
c.date_deadline - c.date_closed))/(3600*24)
|
||||
AS delay_expected
|
||||
"""
|
||||
return select_str
|
||||
|
||||
def _from(self):
|
||||
from_str = """
|
||||
crm_claim c
|
||||
"""
|
||||
return from_str
|
||||
|
||||
def _group_by(self):
|
||||
group_by_str = """
|
||||
GROUP BY c.date, c.user_id, c.team_id, c.stage_id, c.categ_id,
|
||||
c.partner_id, c.company_id, c.create_date, c.priority,
|
||||
c.type_action, c.date_deadline, c.date_closed, c.id
|
||||
"""
|
||||
return group_by_str
|
||||
|
||||
def init(self):
|
||||
"""Display Number of cases And Team Name
|
||||
@param cr: the current row, from the database cursor,
|
||||
"""
|
||||
|
||||
tools.drop_view_if_exists(self.env.cr, self._table)
|
||||
self.env.cr.execute(
|
||||
"""
|
||||
CREATE OR REPLACE VIEW %s AS (
|
||||
%s
|
||||
from
|
||||
%s
|
||||
%s)
|
||||
""",
|
||||
(
|
||||
AsIs(self._table),
|
||||
AsIs(self._select()),
|
||||
AsIs(self._from()),
|
||||
AsIs(self._group_by()),
|
||||
),
|
||||
)
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="view_report_crm_claim_pivot" model="ir.ui.view">
|
||||
<field name="name">crm.claim.report.pivot</field>
|
||||
<field name="model">crm.claim.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="Claims" disable_linking="True">
|
||||
<field name="stage_id" type="row" />
|
||||
<field name="team_id" type="col" />
|
||||
<field name="nbr_claims" type="measure" />
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_report_crm_claim_graph" model="ir.ui.view">
|
||||
<field name="name">crm.claim.report.graph</field>
|
||||
<field name="model">crm.claim.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Claims">
|
||||
<field name="stage_id" />
|
||||
<field name="team_id" />
|
||||
<field name="nbr_claims" type="measure" />
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
<record id="filter_report_crm_claim_workload" model="ir.filters">
|
||||
<field name="name">Workload</field>
|
||||
<field name="model_id">crm.claim.report</field>
|
||||
<field name="user_id" eval="False" />
|
||||
<field
|
||||
name="context"
|
||||
>{'group_by': ['subject'], 'measures': ['email', 'delay_close']}</field>
|
||||
</record>
|
||||
<record id="view_report_crm_claim_filter" model="ir.ui.view">
|
||||
<field name="name">crm.claim.report.select</field>
|
||||
<field name="model">crm.claim.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search">
|
||||
<filter
|
||||
string="My Sales Team(s)"
|
||||
name="My Sales Team(s)"
|
||||
context="{'invisible_team': False}"
|
||||
domain="[('team_id.user_id','=',uid)]"
|
||||
help="My Sales Team(s)"
|
||||
/>
|
||||
<separator />
|
||||
<filter
|
||||
string="My Company"
|
||||
name="My Company"
|
||||
domain="[('company_id.user_ids','=',uid)]"
|
||||
help="My Company"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
<separator />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="user_id" string="Salesperson" />
|
||||
<field
|
||||
name="team_id"
|
||||
string="Sales Team"
|
||||
context="{'invisible_team': False}"
|
||||
/>
|
||||
<group expand="0" string="Extended Filters...">
|
||||
<field
|
||||
name="partner_id"
|
||||
filter_domain="[('partner_id','child_of',self)]"
|
||||
/>
|
||||
<field name="stage_id" domain="[('team_ids', '=', 'team_id')]" />
|
||||
<field name="categ_id" />
|
||||
<field name="priority" />
|
||||
<field name="type_action" />
|
||||
<field name="create_date" />
|
||||
<field name="date_closed" />
|
||||
<field name="date_deadline" />
|
||||
</group>
|
||||
<group expand="1" string="Group By">
|
||||
<filter
|
||||
string="Salesperson"
|
||||
name="Salesperson"
|
||||
context="{'group_by':'user_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Partner"
|
||||
name="partner"
|
||||
context="{'group_by':'partner_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Stage"
|
||||
name="Stage"
|
||||
context="{'group_by':'stage_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Category"
|
||||
name="Category"
|
||||
context="{'group_by':'categ_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Company"
|
||||
name="Company"
|
||||
context="{'group_by':'company_id'}"
|
||||
groups="base.group_multi_company"
|
||||
/>
|
||||
<separator />
|
||||
<filter
|
||||
string="Creation Month"
|
||||
name="Creation Month"
|
||||
context="{'group_by':'claim_date:month'}"
|
||||
help="Month of claim"
|
||||
/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_report_crm_claim" model="ir.actions.act_window">
|
||||
<field name="name">Claims Analysis</field>
|
||||
<field name="res_model">crm.claim.report</field>
|
||||
<field name="view_mode">pivot,graph</field>
|
||||
<field
|
||||
name="context"
|
||||
>{"search_default_year":1,"search_default_User":1,"search_default_This Month":1,'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
<field name="search_view_id" ref="view_report_crm_claim_filter" />
|
||||
<field name="view_id" />
|
||||
<!-- force empty -->
|
||||
<field
|
||||
name="help"
|
||||
>Have a general overview of all claims processed in the system by sorting them with specific criteria.</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Claims"
|
||||
id="menu_report_crm_claim_tree"
|
||||
action="action_report_crm_claim"
|
||||
parent="crm.crm_menu_report"
|
||||
sequence="15"
|
||||
/>
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue