[IMP] hr_timesheet: ease time tracking use of timesheets
Purpose of timesheet module is to track user time. This commit applies various improvements and tweaking to better reflect this purpose. This commit provides some UI improvements * improve views : user_id field is not displayed on 'My Timesheet' action, since it will always be the same user; * simplify menus : 'My timesheet' only for current user's timesheets and 'All timesheet' for everyone's. The latter one allows creating timesheets for someone else, if you have the required access rights; * add calendar views for timesheets * some filters are added to ease time-based filtering of timesheets This commit also reorganizes user groups. Groups are now * new 'timesheet user' group (different from base.group_employee). Users can record their own timesheet. New access rights were added to perform the same operations as before. * 'timesheet manager' (hr_timesheet.group_manager). Users can record timesheets for other users, access to settings and reporting tools.
This commit is contained in:
committed by
Thibault Delavallée
parent
b6beff86b7
commit
a806f96fa2
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<menuitem id="hr_timesheet_menu_configuration" name="Configuration" parent="timesheet_menu_root"
|
||||
groups="group_hr_timesheet_user" sequence="100"/>
|
||||
groups="group_timesheet_manager" sequence="100"/>
|
||||
|
||||
<record id="hr_timesheet_config_settings_view_form" model="ir.ui.view">
|
||||
<field name="name">hr.timesheet.config.settings.view.form</field>
|
||||
|
||||
@@ -1,23 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data>
|
||||
<menuitem id="timesheet_menu_root" name="Timesheets" sequence="55" groups="base.group_user" web_icon="hr_timesheet,static/description/icon_timesheet.png"/>
|
||||
<menuitem id="menu_hr_time_tracking" name="My Timesheet" parent="timesheet_menu_root" sequence="5" />
|
||||
<menuitem id="timesheet_menu_root"
|
||||
name="Timesheets"
|
||||
sequence="55"
|
||||
groups="group_hr_timesheet_user"
|
||||
web_icon="hr_timesheet,static/description/icon_timesheet.png"/>
|
||||
|
||||
<menuitem id="menu_hr_time_tracking"
|
||||
name="Timesheet"
|
||||
parent="timesheet_menu_root"
|
||||
sequence="5"/>
|
||||
|
||||
<!--
|
||||
Timesheet line Views
|
||||
-->
|
||||
<record id="hr_timesheet_line_tree" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.tree.hr_timesheet</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="top" string="Timesheet Activities">
|
||||
<tree editable="top" string="Timesheet Activities" import="false">
|
||||
<field name="date"/>
|
||||
<field name="user_id" required="1" options='{"no_open": True}'/>
|
||||
<field name="name"/>
|
||||
<field name="project_id" required="1"/>
|
||||
<field name="task_id" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/>
|
||||
<field name="unit_amount" string="Duration" sum="Total time" widget="float_time"/>
|
||||
<field name="unit_amount" string="Time (Hours)" sum="Total time" widget="float_time"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_view_tree_user" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.view.tree.with.user</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="inherit_id" ref="hr_timesheet_line_tree"/>
|
||||
<field name="mode">primary</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='date']" position="after">
|
||||
<field name="user_id" required="1" options='{"no_open": True}'/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_hr_timesheet_line_pivot" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.pivot</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
@@ -29,18 +53,58 @@
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_timesheet_line_form" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.form.inherit.hr_timesheet</field>
|
||||
<field name="name">account.analytic.line.form</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_line_form"/>
|
||||
<field name="mode">primary</field>
|
||||
<field name="priority">1</field>
|
||||
<field name="inherit_id" eval="False"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="account_id" position="after">
|
||||
<field name="project_id" required="1"/>
|
||||
<field name="task_id" domain="[('project_id', '=', project_id)]"/>
|
||||
</field>
|
||||
<form string="Analytic Entry">
|
||||
<sheet string="Analytic Entry">
|
||||
<group>
|
||||
<group>
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="project_id" required="1"/>
|
||||
<field name="task_id" domain="[('project_id', '=', project_id)]"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="amount"/>
|
||||
<field name="unit_amount"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_view_form_user" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.tree.with.user</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form"/>
|
||||
<field name="mode">primary</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='company_id']" position="before">
|
||||
<field name="user_id" required="1" options='{"no_open": True}'/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_view_calendar" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.calendar</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar string="Timesheets" date_start="date" color="user_id">
|
||||
<field name="name"/>
|
||||
<field name="project_id"/>
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hr_timesheet_line_search" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.search</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
@@ -51,23 +115,39 @@
|
||||
<field name="project_id"/>
|
||||
<field name="task_id"/>
|
||||
<field name="name"/>
|
||||
<field name="department_id"/>
|
||||
<filter name="mine" string="My Timesheets" domain="[('user_id', '=', uid)]"/>
|
||||
<separator/>
|
||||
<filter name="week" string="This Week"
|
||||
domain="[
|
||||
'&',
|
||||
('date', '>=', (context_today() + relativedelta(weeks=-1,days=1,weekday=0)).strftime('%Y-%m-%d')),
|
||||
('date', '<=', (context_today() + relativedelta(weekday=6)).strftime('%Y-%m-%d')),
|
||||
]"/>
|
||||
<filter name="month" string="This Month"
|
||||
domain="[
|
||||
'&',
|
||||
('date', '>=', (context_today() + relativedelta(day=1)).strftime('%Y-%m-%d')),
|
||||
('date', '<=', (context_today() + relativedelta(months=1, day=1, days=-1)).strftime('%Y-%m-%d')),
|
||||
]"/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Users" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Project" domain="[]" context="{'group_by':'project_id'}"/>
|
||||
<filter string="Task" domain="[]" context="{'group_by':'task_id'}"/>
|
||||
<filter string="Product" domain="[]" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Timesheet Month" domain="[]" context="{'group_by':'date'}" help="Timesheet by Month"/>
|
||||
<filter string="Users" name="groupby_user" domain="[]" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Project" name="groupby_project" domain="[]" context="{'group_by':'project_id'}"/>
|
||||
<filter string="Task" name="groupby_task" domain="[]" context="{'group_by':'task_id'}"/>
|
||||
<filter string="Timesheet Month" name="groupby_date" domain="[]" context="{'group_by':'date'}" help="Timesheet by Month"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
Menus and Actions
|
||||
-->
|
||||
<record id="act_hr_timesheet_line" model="ir.actions.act_window">
|
||||
<field name="name">Activities</field>
|
||||
<field name="name">My Timesheets</field>
|
||||
<field name="res_model">account.analytic.line</field>
|
||||
<field name="domain">[('project_id', '!=', False)]</field>
|
||||
<field name="context">{"search_default_today":1}</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('project_id', '!=', False), ('user_id', '=', uid)]</field>
|
||||
<field name="context">{"search_default_week":1}</field>
|
||||
<field name="search_view_id" ref="hr_timesheet_line_search"/>
|
||||
<field name="help" type="html">
|
||||
<p class="oe_view_nocontent_create">
|
||||
@@ -80,22 +160,65 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="act_hr_timesheet_line_view_tree">
|
||||
<record id="act_hr_timesheet_line_view_tree" model="ir.actions.act_window.view">
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="sequence">1</field>
|
||||
<field name="view_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
|
||||
<field name="sequence" eval="4"/>
|
||||
<field name="view_id" ref="hr_timesheet_line_tree"/>
|
||||
<field name="act_window_id" ref="act_hr_timesheet_line"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="act_hr_timesheet_line_view_form">
|
||||
<record id="act_hr_timesheet_line_view_form" model="ir.actions.act_window.view">
|
||||
<field name="view_mode">form</field>
|
||||
<field name="sequence">2</field>
|
||||
<field name="view_id" ref="hr_timesheet.hr_timesheet_line_form"/>
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_id" ref="hr_timesheet_line_form"/>
|
||||
<field name="act_window_id" ref="act_hr_timesheet_line"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_hr_working_hours" parent="menu_hr_time_tracking" action="act_hr_timesheet_line"
|
||||
name="Detailed Activities"/>
|
||||
<record id="timesheet_action_view_calendar" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="8"/>
|
||||
<field name="view_mode">calendar</field>
|
||||
<field name="view_id" ref="timesheet_view_calendar"/>
|
||||
<field name="act_window_id" ref="act_hr_timesheet_line"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="timesheet_menu_activity_mine"
|
||||
name="My Timesheets"
|
||||
parent="menu_hr_time_tracking"
|
||||
action="act_hr_timesheet_line"/>
|
||||
|
||||
<record id="timesheet_action_all" model="ir.actions.act_window">
|
||||
<field name="name">All Timesheets</field>
|
||||
<field name="res_model">account.analytic.line</field>
|
||||
<field name="search_view_id" ref="hr_timesheet_line_search"/>
|
||||
<field name="domain">[('project_id', '!=', False)]</field>
|
||||
<field name="context">{'search_default_week':1, 'search_default_groupby_user':1}</field>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_all_tree" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="4"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="timesheet_view_tree_user"/>
|
||||
<field name="act_window_id" ref="timesheet_action_all"/>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_all_form" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="timesheet_view_form_user"/>
|
||||
<field name="act_window_id" ref="timesheet_action_all"/>
|
||||
</record>
|
||||
|
||||
<record id="timesheet_action_view_all_calendar" model="ir.actions.act_window.view">
|
||||
<field name="sequence" eval="8"/>
|
||||
<field name="view_mode">calendar</field>
|
||||
<field name="view_id" ref="timesheet_view_calendar"/>
|
||||
<field name="act_window_id" ref="timesheet_action_all"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="timesheet_menu_activity_all"
|
||||
name="All Timesheets"
|
||||
parent="menu_hr_time_tracking"
|
||||
action="timesheet_action_all"/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -38,10 +38,15 @@
|
||||
<field name="act_window_id" ref="act_hr_timesheet_report"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_timesheets_reports"
|
||||
name="Reporting"
|
||||
parent="timesheet_menu_root"
|
||||
groups="hr_timesheet.group_timesheet_manager"
|
||||
sequence="99"/>
|
||||
|
||||
<menuitem id="menu_timesheets_reports" name="Reporting"
|
||||
parent="timesheet_menu_root" sequence="99" groups="hr_timesheet.group_hr_timesheet_user"/>
|
||||
<menuitem id="menu_hr_activity_analysis" parent="menu_timesheets_reports" action="act_hr_timesheet_report"
|
||||
<menuitem id="menu_hr_activity_analysis"
|
||||
parent="menu_timesheets_reports"
|
||||
action="act_hr_timesheet_report"
|
||||
name="Activity Analysis"/>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -1,13 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
<record id="group_hr_timesheet_user" model="res.groups">
|
||||
<field name="name">Officer</field>
|
||||
<field name="category_id" ref="base.module_category_hr_timesheet"/>
|
||||
<field name="implied_ids" eval="[(4, ref('hr.group_hr_user'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.default_user" model="res.users">
|
||||
<field name="groups_id" eval="[(4,ref('hr_timesheet.group_hr_timesheet_user'))]"/>
|
||||
</record>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="group_hr_timesheet_user" model="res.groups">
|
||||
<field name="name">User</field>
|
||||
<field name="category_id" ref="base.module_category_hr_timesheet"/>
|
||||
<field name="implied_ids" eval="[(4, ref('hr.group_hr_user'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="group_timesheet_manager" model="res.groups">
|
||||
<field name="name">Manager</field>
|
||||
<field name="category_id" ref="base.module_category_hr_timesheet"/>
|
||||
<field name="implied_ids" eval="[(4, ref('group_hr_timesheet_user'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="base.default_user" model="res.users">
|
||||
<field name="groups_id" eval="[(4,ref('group_hr_timesheet_user'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
<data noupdate="0">
|
||||
<!-- This rule is in noupdate mode because it can be modify by other advanced modules -->
|
||||
<record id="timesheet_line_rule_user" model="ir.rule">
|
||||
<field name="name">account.analytic.line.timesheet.user</field>
|
||||
<field name="model_id" ref="analytic.model_account_analytic_line"/>
|
||||
<field name="domain_force">[('user_id', '=', user.id), ('project_id', '!=', False)]</field>
|
||||
<field name="groups" eval="[(4, ref('group_hr_timesheet_user'))]"/>
|
||||
<field name="perm_create" eval="1"/>
|
||||
<field name="perm_write" eval="1"/>
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
<field name="perm_read" eval="0"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="timesheet_line_rule_manager" model="ir.rule">
|
||||
<field name="name">account.analytic.line.timesheet.manager</field>
|
||||
<field name="model_id" ref="analytic.model_account_analytic_line"/>
|
||||
<field name="domain_force">[('project_id', '!=', False)]</field>
|
||||
<field name="groups" eval="[(4, ref('group_timesheet_manager'))]"/>
|
||||
<field name="perm_create" eval="1"/>
|
||||
<field name="perm_write" eval="1"/>
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
<field name="perm_read" eval="1"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
</odoo>
|
||||
@@ -1,6 +1,8 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hr_account_analytic_line,analytic.account.analytic.line,analytic.model_account_analytic_line,hr_timesheet.group_hr_timesheet_user,1,1,1,1
|
||||
access_hr_account_analytic_line_employee,analytic.account.analytic.line employee,analytic.model_account_analytic_line,base.group_user,1,1,1,1
|
||||
access_product_product_user,product.product user,product.model_product_product,hr_timesheet.group_hr_timesheet_user,1,1,1,1
|
||||
access_product_template_hr_timesheet,product.template.hr.timesheet,product.model_product_template,hr_timesheet.group_hr_timesheet_user,1,1,1,1
|
||||
access_product_uom_hr_timesheet,product.uom.hr.timesheet,product.model_product_uom,hr_timesheet.group_hr_timesheet_user,1,1,1,1
|
||||
access_account_analytic_line_user,analytic.account.analytic.line.timesheet.user,analytic.model_account_analytic_line,hr_timesheet.group_hr_timesheet_user,1,1,1,1
|
||||
access_account_analytic_user,analytic.account.analytic.timesheet.user,analytic.model_account_analytic_account,hr_timesheet.group_hr_timesheet_user,1,1,0,0
|
||||
access_product_product_user,product.product.timesheet.user,product.model_product_product,hr_timesheet.group_hr_timesheet_user,1,1,1,0
|
||||
access_product_template_timesheet_user,product.template.timesheet.user,product.model_product_template,hr_timesheet.group_hr_timesheet_user,1,1,1,0
|
||||
access_product_uom_hr_timesheet,product.uom.timesheet.user,product.model_product_uom,hr_timesheet.group_hr_timesheet_user,1,0,0,0
|
||||
access_project_project,project.project.timesheet.user,model_project_project,hr_timesheet.group_hr_timesheet_user,1,0,0,0
|
||||
access_project_task,project.task.timesheet.user,model_project_task,hr_timesheet.group_hr_timesheet_user,1,1,0,0
|
||||
|
Reference in New Issue
Block a user