Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Upgrade mgmtsystem_claim to v9.0 #141

Merged
merged 16 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mgmtsystem_claim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import models
from . import reports
13 changes: 7 additions & 6 deletions mgmtsystem_claim/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
Expand All @@ -20,7 +20,7 @@
##############################################################################
{
"name": "Management System - Claim",
"version": "8.0.1.1.0",
"version": "9.0.1.1.1",
"author": "Savoir-faire Linux,Odoo Community Association (OCA)",
"website": "http://www.savoirfairelinux.com",
"license": "AGPL-3",
Expand All @@ -38,11 +38,12 @@
'security/mgmtsystem_claim_security.xml',
'data/claim_sequence.xml',
'data/mgmtsystem_claim_stage.xml',
'views/menus.xml',
'views/mgmtsystem_claim.xml',
'views/mgmtsystem_claim_stage.xml',
'reports/mgmtsystem_claim_report.xml',
'workflow_mgmtsystem_claim.xml',
'views/board_mgmtsystem_claim.xml',
'views/menus.xml',
'views/mgmtsystem_claim_stage.xml',

],
'installable': False,
'installable': True,
}
6 changes: 0 additions & 6 deletions mgmtsystem_claim/data/claim_sequence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
<openerp>
<data noupdate="1">

<!-- Sequences for mgmtsystem.claim -->
<record id="seq_type_mgmtsystem_claim" model="ir.sequence.type">
<field name="name">Management System Claim</field>
<field name="code">mgmtsystem.claim</field>
</record>

<record id="seq_mgmtsystem_claim" model="ir.sequence">
<field name="name">Management System Claim</field>
<field name="code">mgmtsystem.claim</field>
Expand Down
12 changes: 9 additions & 3 deletions mgmtsystem_claim/data/mgmtsystem_claim_stage.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
<openerp>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>

<record id="stage_draft" model="mgmtsystem.claim.stage">
<field name="name">draft</field>
<field name="sequence">0</field>
<field name="case_default" eval="True"/>
</record>

<record id="stage_pending" model="mgmtsystem.claim.stage">
<field name="name">pending</field>
<field name="sequence">250</field>
<field name="case_default" eval="True"/>
</record>

<record id="stage_open" model="mgmtsystem.claim.stage">
<field name="name">open</field>
<field name="sequence">500</field>
<field name="case_default" eval="True"/>
</record>

<record id="stage_close" model="mgmtsystem.claim.stage">
<field name="name">close</field>
<field name="sequence">750</field>
<field name="case_default" eval="True"/>
</record>

<record id="stage_cancel" model="mgmtsystem.claim.stage">
<field name="name">cancel</field>
<field name="sequence">750</field>
<field name="sequence">1000</field>
<field name="case_default" eval="True"/>
</record>

</data>
</openerp>
</odoo>
9 changes: 5 additions & 4 deletions mgmtsystem_claim/models/mgmtsystem_claim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
Expand All @@ -21,7 +21,7 @@
from openerp import fields, models, api


class mgmtsystem_claim(models.Model):
class MgmtsystemClaim(models.Model):
_name = "mgmtsystem.claim"
_description = "Claim"
_inherit = "crm.claim"
Expand Down Expand Up @@ -59,6 +59,7 @@ def get_default_stage(self):
@api.model
def create(self, vals):
vals.update({
'reference': self.env['ir.sequence'].get('mgmtsystem.claim')
'reference':
self.env['ir.sequence'].next_by_code('mgmtsystem.claim')
})
return super(mgmtsystem_claim, self).create(vals)
return super(MgmtsystemClaim, self).create(vals)
3 changes: 3 additions & 0 deletions mgmtsystem_claim/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import mgmtsystem_claim_report
51 changes: 51 additions & 0 deletions mgmtsystem_claim/reports/mgmtsystem_claim_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-

from openerp import fields, models
from openerp import tools


class MgmtsystemtClaimReport(models.Model):
"""Management System Claim Report."""

_name = "mgmtsystem.claim.report"
_auto = False
_description = "Management System Claim Report"
_rec_name = 'id'

# Compute data
number_of_claims = fields.Integer('# of claims', readonly=True)
age = fields.Integer('Age', readonly=True)
number_of_days_to_close = fields.Integer(
'# of days to close', readonly=True)
number_of_exceedings_days = fields.Integer(
'# of exceedings days', readonly=True)

# Grouping view
create_date = fields.Datetime('Create Date', readonly=True, select=True)
write_date = fields.Datetime('Update Date', readonly=True, select=True)
date_closed = fields.Datetime('Close Date', readonly=True, select=True)
date_deadline = fields.Date('Deadline', readonly=True, select=True)
user_id = fields.Many2one('res.users', 'User', readonly=True)
stage_id = fields.Many2one(
'mgmtsystem.claim.stage', 'Stage', readonly=True)

def init(self, cr):
"""Display a pivot view of claim."""
tools.drop_view_if_exists(cr, 'mgmtsystem_claim_report')
cr.execute("""
CREATE OR REPLACE VIEW mgmtsystem_claim_report AS (
select
m.id,
m.date_closed as date_closed,
m.date_deadline as date_deadline,
m.user_id,
m.stage_id,
m.create_date as create_date,
count(*) AS number_of_claims
from
mgmtsystem_claim m
group by m.user_id, m.stage_id, m.date, \
m.create_date,m.date_deadline, \
m.date_closed, m.id
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This group by operation is redundant, since it groups by id.
IMO skip completely the report model, and instead just add a Pivot view to the mgmtsystem.claim model.

)
""")
46 changes: 46 additions & 0 deletions mgmtsystem_claim/reports/mgmtsystem_claim_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<odoo>
<data>

<!-- Management System Claim Report Pivot View -->

<record id="view_report_mgmtsystem_claim_pivot" model="ir.ui.view">
<field name="name">mgmtsystem.claim.report.pivot</field>
<field name="model">mgmtsystem.claim.report</field>
<field name="arch" type="xml">
<pivot string="Actions" disable_linking="True">
<field name="stage_id" type="row"/>
<field name="user_id" type="col"/>
<field name="number_of_claims" type="measure"/>
</pivot>
</field>
</record>

<!-- Management System Claim Report Graph View -->

<record id="view_report_mgmtsystem_claim_graph" model="ir.ui.view">
<field name="name">mgmtsystem.claim.report.graph</field>
<field name="model">mgmtsystem.claim.report</field>
<field name="arch" type="xml">
<graph string="Actions">
<field name="stage_id"/>
<field name="user_id"/>
<field name="number_of_claims" type="measure"/>
</graph>
</field>
</record>

<!-- Management system Claim Report Action -->

<record id="action_report_mgmtsystem_claim" model="ir.actions.act_window">
<field name="name">Management System Analysis</field>
<field name="res_model">mgmtsystem.claim.report</field>
<field name="view_type">form</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="view_id"></field> <!-- force empty -->
<field name="help">Have a general overview of all claims processed in the system by sorting them with specific criteria.</field>
</record>

</data>

</odoo>
1 change: 1 addition & 0 deletions mgmtsystem_claim/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_mgmtsystem_claim","mgmtsystem.claim.user","model_mgmtsystem_claim","base.group_user",1,1,1,0
"access_mgmtsystem_claim_stage","access_mgmtsystem_claim_stage","model_mgmtsystem_claim_stage","base.group_user",1,0,0,0
"access_mgmtsystem_claim_report","access_mgmtsystem_claim_report","model_mgmtsystem_claim_report","base.group_user",1,0,0,0
2 changes: 1 addition & 1 deletion mgmtsystem_claim/tests/test_create_claim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-

from openerp.tests import common

Expand Down
25 changes: 0 additions & 25 deletions mgmtsystem_claim/views/board_mgmtsystem_claim.xml

This file was deleted.

6 changes: 6 additions & 0 deletions mgmtsystem_claim/views/menus.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<openerp>
<data>

<menuitem name="Claims"
id="menu_report_mgmtsystem_action_tree"
action="action_report_mgmtsystem_claim"
parent="mgmtsystem.menu_mgmtsystem_report"
sequence="20"/>

<menuitem
id="menu_config_claim"
name="Claims"
Expand Down
9 changes: 4 additions & 5 deletions mgmtsystem_claim/views/mgmtsystem_claim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<field name="stage_id" />
<field name="date_deadline" invisible="1"/>
<field name="date_closed" invisible="1"/>
<field name="company_id" group="base.group_multi_company"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</record>
Expand All @@ -38,12 +38,12 @@
<field name="name"/>
<field name="date"/>
<field name="reference"/>
<field name="company_id" group="base.group_multi_company"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<group colspan="4" col="4" groups="base.group_user">
<field name="user_id"/>
<field name="priority"/>
<field name="section_id"/>
<field name="team_id"/>
<field name="date_deadline"/>
</group>
<group colspan="4" col="4">
Expand All @@ -59,8 +59,7 @@
<group colspan="2" col="2" groups="base.group_user">
<separator colspan="2" string="Responsibilities"/>
<field name="user_fault"/>
<field name="categ_id" widget="selection"
domain="[('object_id.model', '=', 'crm.claim')]"/>
<field name="categ_id" widget="selection"/>
<field name="ref"/>
</group>
<separator colspan="4" string="Claim/Action Description" groups="base.group_user"/>
Expand Down
2 changes: 1 addition & 1 deletion mgmtsystem_claim/workflow_mgmtsystem_claim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- Template -->
<record id="action_email_template_reminder_action"
model="email.template">
model="mail.template">
<field name="name">Notify the person in charge of the new claim</field>
<field name="email_from">${object.create_uid.company_id.email or 'noreply@localhost.com'}</field>
<field name="subject">${object.name}</field>
Expand Down