-
Notifications
You must be signed in to change notification settings - Fork 76
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
[12.0][[BR001548]][MIG] timesheet_activity_report :Migration to 12.0 #238
base: 12.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
|
||
========================= | ||
Timesheet Activity Report | ||
========================= | ||
|
||
This module extends the functionality of project adding a timesheet report listed at timesheet completion analysis. | ||
You can use this report to communicate the timesheet analysis to the project members. | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/Elico-Corp/odoo-addons/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smash it by providing detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
|
||
Contributors | ||
------------ | ||
|
||
* Eric Caudal <[email protected]> | ||
* Sébastien Maillard <[email protected]> | ||
* Reinhard Sheng <[email protected]> | ||
|
||
|
||
This module is maintained by Elico Corporation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing part of the footer it seems |
||
|
||
Elico Corp is an innovative actor in China, Hong-Kong and Singapore servicing | ||
well known international companies and as well as local mid-sized businesses. | ||
Since 2010, our seasoned Sino-European consultants have been providing full | ||
range Odoo services: | ||
|
||
* Business consultancy for Gap analysis, BPM, operational work-flows review. | ||
* Ready-to-use ERP packages aimed at starting businesses. | ||
* Odoo implementation for manufacturing, international trading, service industry | ||
and e-commerce. | ||
* Connectors and integration with 3rd party software (Magento, Taobao, Coswin, | ||
Joomla, Prestashop, Tradevine etc...). | ||
* Odoo Support services such as developments, training, maintenance and hosting. | ||
|
||
Our headquarters are located in Shanghai with branch in Singapore servicing | ||
customers from all over Asia Pacific. | ||
|
||
Contact information: `Sales <[email protected]>`__ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import report |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||
# © 2016-2019 Elico Corp (https://www.elico-corp.com) | ||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||||||
{ | ||||||
'name': 'Timesheet Activities Report', | ||||||
'version': '12.0.1.1.0', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
'category': 'Human Resources', | ||||||
'depends': [ | ||||||
'hr_timesheet', | ||||||
'helpdesk_timesheet', | ||||||
'business_requirement_deliverable_project', | ||||||
'project_task_category' | ||||||
], | ||||||
'author': 'Elico Corp', | ||||||
'support': '[email protected]', | ||||||
'license': 'LGPL-3', | ||||||
'website': 'https://www.elico-corp.com', | ||||||
'data': [ | ||||||
'report/timesheet_activity_report_view.xml', | ||||||
'security/ir.model.access.csv', | ||||||
], | ||||||
'installable': True, | ||||||
'application': False | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import timesheet_activity_report |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# © 2016-2019 Elico Corp (https://www.elico-corp.com) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). | ||
|
||
from odoo import models, fields, tools | ||
|
||
|
||
class TimesheetReport(models.Model): | ||
""" | ||
Timesheet Activities Report. | ||
""" | ||
_name = "timesheet.activity.report" | ||
# Database table should not be created, use init() instead | ||
_auto = False | ||
_description = "Timesheet Activities Report" | ||
# Field used for the Name | ||
_rec_name = 'activity_name' | ||
|
||
id = fields.Integer('Id', readonly=True) | ||
activity_type = fields.Selection( | ||
[ | ||
('task', 'Task'), | ||
('issue', 'Issue'), | ||
('timesheet', 'Timesheet'), | ||
], 'Type', readonly=True, | ||
help="Type is based on the origin of the input (Task, Issue or " | ||
"Timesheet Activities)") | ||
description = fields.Char('Description', readonly=True) | ||
hours = fields.Float( | ||
'Time spent', digits=(16, 2), readonly=True, | ||
help="Time spent on timesheet") | ||
user_id = fields.Many2one('res.users', 'User', readonly=True) | ||
product_id = fields.Many2one('product.product', 'Product', readonly=True) | ||
date = fields.Date('Date', readonly=True) | ||
project_id = fields.Many2one('project.project', 'Project', readonly=True) | ||
project_state = fields.Char('State', readonly=True, help="Project State") | ||
activity_stage_id = fields.Many2one( | ||
'project.task.type', 'Stage', | ||
readonly=True, help="Activity Stage") | ||
account_id = fields.Many2one( | ||
'account.analytic.account', 'Analytic account', readonly=True) | ||
activity_id = fields.Char( | ||
'Activity id', readonly=True, help="Task id or Issue id") | ||
activity_name = fields.Char( | ||
'Activity name', readonly=True, help="Task name or Issue name") | ||
categ_id = fields.Many2one( | ||
'project.category.main', 'Task Cat.', | ||
readonly=True, help="Task Category") | ||
br_id = fields.Many2one( | ||
'business.requirement', 'Bus. requ.', | ||
readonly=True, help="Business requirement") | ||
partner_id = fields.Many2one( | ||
'res.partner', 'Customer', readonly=True) | ||
project_categ_id = fields.Many2one( | ||
'project.project.category', | ||
'Project Cat.', readonly=True, help="Project Category") | ||
|
||
def init(self, cr): | ||
""" | ||
Timesheet Activities Report. | ||
""" | ||
tools.drop_view_if_exists(cr, 'timesheet_activity_report') | ||
cr.execute(""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @seb-elico probably requires that you have a deep look at current model structure |
||
CREATE OR REPLACE VIEW timesheet_activity_report AS ( | ||
SELECT | ||
al.id, | ||
-- Check if the timesheet is linked to a task | ||
-- or an issue | ||
CASE WHEN tw.id IS NOT NULL THEN 'task' | ||
ELSE ( | ||
CASE WHEN i.id IS NOT NULL THEN 'issue' | ||
-- Timesheet created in the timesheet | ||
-- activities panel | ||
ELSE ( | ||
CASE WHEN al.id IS NOT NULL THEN 'timesheet' | ||
-- No timesheet attached to this | ||
-- task/project/BR | ||
ELSE NULL | ||
END | ||
) | ||
END | ||
) | ||
END AS activity_type, | ||
-- Description from the task first | ||
-- because the one in the timesheet | ||
-- is wrong when it's linked to a task | ||
al.name AS description, | ||
al.unit_amount AS hours, | ||
al.user_id, | ||
al.product_id, | ||
al.date, | ||
p.id AS project_id, | ||
p.state AS project_state, | ||
COALESCE(t.stage_id, i.stage_id) AS activity_stage_id, | ||
COALESCE(a.id, al.account_id) AS account_id, | ||
COALESCE(t.id, i.id) AS activity_id, | ||
COALESCE(t.name, i.name) AS activity_name, | ||
t.categ_id, | ||
b.id AS br_id, | ||
a.partner_id, | ||
p.project_categ_id | ||
FROM | ||
account_analytic_line al | ||
-- Link with the issue | ||
LEFT OUTER JOIN helpdesk_ticket h | ||
ON h.id = al.helpdesk_ticket_id | ||
-- Link with the project | ||
LEFT OUTER JOIN project_project p | ||
ON p.id = COALESCE(t.project_id, i.project_id) | ||
-- Link with the analytic account | ||
LEFT OUTER JOIN account_analytic_account a | ||
ON a.id = p.analytic_account_id | ||
-- Link with the BR | ||
LEFT OUTER JOIN business_requirement b | ||
ON b.id = p.business_requirement_id | ||
)""") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- # © 2016-2019 Elico Corp (https://www.elico-corp.com) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> | ||
<odoo> | ||
|
||
<record id="action_timesheet_activity_tree" model="ir.ui.view"> | ||
<field name="name">Timesheet Activities Tree</field> | ||
<field name="model">timesheet.activity.report</field> | ||
<field name="arch" type="xml"> | ||
<tree string="Timesheet Activities Tree"> | ||
<field name="partner_id"/> | ||
<field name="account_id"/> | ||
<field name="project_categ_id"/> | ||
<field name="project_id"/> | ||
<field name="project_state"/> | ||
<field name="br_id"/> | ||
<field name="activity_id" string="ID"/> | ||
<field name="activity_type"/> | ||
<field name="categ_id"/> | ||
<field name="activity_name"/> | ||
<field name="activity_stage_id"/> | ||
<field name="date"/> | ||
<field name="description"/> | ||
<field name="user_id"/> | ||
<field name="product_id"/> | ||
<field name="hours"/> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="action_timesheet_activity_pivot" model="ir.ui.view"> | ||
<field name="name">Timesheet Activities Pivot Table</field> | ||
<field name="model">timesheet.activity.report</field> | ||
<field name="arch" type="xml"> | ||
<graph type="pivot"> | ||
<field name="hours" type="measure"/> | ||
</graph> | ||
</field> | ||
</record> | ||
|
||
<record id="action_timesheet_activity_report" | ||
model="ir.actions.act_window"> | ||
<field name="name">Timesheet Completion Analysis</field> | ||
<field name="res_model">timesheet.activity.report</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,graph</field> | ||
<field name="context">{}</field> | ||
<field name="domain">[]</field> | ||
</record> | ||
|
||
<record model="ir.ui.view" id="timesheet_activity_search"> | ||
<field name="name">Timesheet Completion Analysis Search</field> | ||
<field name="model">timesheet.activity.report</field> | ||
<field name="arch" type="xml"> | ||
<search string="Timesheet search"> | ||
<field name="activity_id"/> | ||
<field name="account_id"/> | ||
<field name="project_id"/> | ||
<field name="project_state"/> | ||
<field name="user_id"/> | ||
<field name="br_id"/> | ||
<field name="partner_id"/> | ||
<field name="activity_stage_id"/> | ||
<field name="categ_id"/> | ||
<field name="project_categ_id"/> | ||
<filter string="Current Month" | ||
domain="[('date', '>=', datetime.datetime.now().strftime('%%Y-%%m-01'))]"/> | ||
<filter string="Previous Month" | ||
name="previous_month" | ||
domain="[('date', '>=', (context_today() - relativedelta(months=1)).strftime('%%Y-%%m-01')), ('date', '<', time.strftime('%%Y-%%m-01'))]"/> | ||
<separator/> | ||
<group expand="0" string="Group By"> | ||
<filter name="analytic_account" string="Analytic Account" domain="[]" | ||
context="{'group_by': 'account_id'}"/> | ||
<filter name="project" string="Project" domain="[]" | ||
context="{'group_by': 'project_id'}"/> | ||
<filter name="state" string="State" domain="[]" | ||
context="{'group_by': 'project_state'}"/> | ||
<filter name="user" string="User" domain="[]" | ||
context="{'group_by': 'user_id'}"/> | ||
<filter name="business_requirement" string="Business Requirement" domain="[]" | ||
context="{'group_by': 'br_id'}"/> | ||
<filter name="customer" string="Customer" domain="[]" | ||
context="{'group_by': 'partner_id'}"/> | ||
<filter name="activity_stage" string="Activity stage" domain="[]" | ||
context="{'group_by': 'activity_stage_id'}"/> | ||
<filter name="task_category" string="Task category" domain="[]" | ||
context="{'group_by': 'categ_id'}"/> | ||
<filter name="project_category" string="Project category" domain="[]" | ||
context="{'group_by': 'project_categ_id'}"/> | ||
</group> | ||
</search> | ||
</field> | ||
</record> | ||
|
||
<menuitem name="Timesheet Completion Analysis" | ||
id="menu_timesheet_activity_report_tree" | ||
parent="hr.menu_hr_reporting" | ||
action="action_timesheet_activity_report" | ||
sequence="1"/> | ||
|
||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_timesheet_activity_report,timesheet.activity.report all,model_timesheet_activity_report,base.group_user,1,1,1,1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove