diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_timesheet/views | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/hr_timesheet/views')
| -rw-r--r-- | addons/hr_timesheet/views/assets.xml | 13 | ||||
| -rw-r--r-- | addons/hr_timesheet/views/hr_timesheet_portal_templates.xml | 139 | ||||
| -rw-r--r-- | addons/hr_timesheet/views/hr_timesheet_views.xml | 322 | ||||
| -rw-r--r-- | addons/hr_timesheet/views/hr_views.xml | 71 | ||||
| -rw-r--r-- | addons/hr_timesheet/views/project_portal_templates.xml | 80 | ||||
| -rw-r--r-- | addons/hr_timesheet/views/project_views.xml | 281 | ||||
| -rw-r--r-- | addons/hr_timesheet/views/res_config_settings_views.xml | 123 |
7 files changed, 1029 insertions, 0 deletions
diff --git a/addons/hr_timesheet/views/assets.xml b/addons/hr_timesheet/views/assets.xml new file mode 100644 index 00000000..b4d25486 --- /dev/null +++ b/addons/hr_timesheet/views/assets.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<odoo> + <template id="assets_backend" name="timesheet assets" inherit_id="web.assets_backend"> + <xpath expr="." position="inside"> + <link type="text/scss" href="/hr_timesheet/static/src/scss/timesheets_task_form.scss" rel="stylesheet"/> + <script type="text/javascript" src="/hr_timesheet/static/src/js/task_with_hours.js"></script> + <script type="text/javascript" src="/hr_timesheet/static/src/js/timesheet_uom.js"/> + <script type="text/javascript" src="/hr_timesheet/static/src/js/timesheet_factor.js"/> + <script type="text/javascript" src="/hr_timesheet/static/src/js/timesheet_config_form_view.js"/> + <script type="text/javascript" src="/hr_timesheet/static/src/js/qr_code_action.js"/> + </xpath> + </template> +</odoo> diff --git a/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml b/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml new file mode 100644 index 00000000..4385bbdd --- /dev/null +++ b/addons/hr_timesheet/views/hr_timesheet_portal_templates.xml @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <template id="portal_layout" name="Portal layout: timesheet menu entry" inherit_id="portal.portal_breadcrumbs" priority="35"> + <xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside"> + <li t-if="page_name == 'timesheet' or timesheet" t-attf-class="breadcrumb-item #{'active' if not timesheet else ''}"> + <t>Timesheets</t> + </li> + </xpath> + </template> + + <template id="portal_my_home_timesheet" name="Show Timesheets" customize_show="True" inherit_id="portal.portal_my_home" priority="45"> + <xpath expr="//div[hasclass('o_portal_docs')]" position="inside"> + <t t-call="portal.portal_docs_entry"> + <t t-set="title">Timesheets</t> + <t t-set="url" t-value="'/my/timesheets'"/> + <t t-set="placeholder_count" t-value="'timesheet_count'"/> + </t> + </xpath> + </template> + + <template id="portal_my_timesheets" name="My Timesheets"> + <t t-call="portal.portal_layout"> + <t t-set="breadcrumbs_searchbar" t-value="True"/> + + <t t-call="portal.portal_searchbar"> + <t t-set="title">Timesheets</t> + </t> + <t t-if="not grouped_timesheets"> + <div class="alert alert-warning mt8" role="alert"> + There are no timesheets. + </div> + </t> + <t t-if="grouped_timesheets"> + <t t-call="portal.portal_table"> + <t t-foreach="grouped_timesheets" t-as="timesheets_with_hours"> + <t t-set="timesheets" t-value="timesheets_with_hours[0]"/> + <t t-set="hours_spent" t-value="timesheets_with_hours[1]"/> + <thead style="font-size: 0.8rem"> + <tr t-if="not groupby =='none'" t-attf-class="{{'thead-light'}}"> + <t t-if="groupby == 'project'"> + <th t-if="groupby == 'project'" colspan="5"> + <em class="font-weight-normal text-muted">Timesheets for project:</em> + <span t-field="timesheets[0].project_id.name"/> + </th> + <th colspan="1" class="text-right text-muted"> + <t t-if="is_uom_day"> + Total: <span class="text-muted" t-esc="timesheets[0]._convert_hours_to_days(hours_spent)" t-options='{"widget": "timesheet_uom"}'/> + </t> + <t t-else=""> + Total: <span class="text-muted" t-esc="hours_spent" t-options='{"widget": "float_time"}'/> + </t> + </th> + </t> + <t t-elif="groupby == 'task'"> + <th colspan="5"> + <em class="font-weight-normal text-muted">Timesheets for task:</em> + <span t-field="timesheets[0].task_id.name"/> + </th> + <th colspan="1" class="text-right text-muted"> + <t t-if="is_uom_day"> + Total: <span t-esc="timesheets[0]._convert_hours_to_days(hours_spent)" t-options='{"widget": "timesheet_uom"}'/> + </t> + <t t-else=""> + Total: <span t-esc="hours_spent" t-options='{"widget": "float_time"}'/> + </t> + </th> + </t> + <t t-elif="groupby == 'date'"> + <th colspan="5"> + <em class="font-weight-normal text-muted">Timesheets on </em> + <span t-field="timesheets[0].date"/> + </th> + <th colspan="1" class="text-right text-muted"> + <t t-if="is_uom_day"> + Total: <span t-esc="timesheets[0]._convert_hours_to_days(hours_spent)" t-options='{"widget": "timesheet_uom"}'/> + </t> + <t t-else=""> + Total: <span t-esc="hours_spent" t-options='{"widget": "float_time"}'/> + </t> + </th> + </t> + <t t-elif="groupby == 'employee'"> + <th colspan="5"> + <em class="font-weight-normal text-muted">Timesheets for employee:</em> + <span t-field="timesheets[0].employee_id.name"/> + </th> + <th colspan="1" class="text-right text-muted"> + <t t-if="is_uom_day"> + Total: <span t-esc="timesheets[0]._convert_hours_to_days(hours_spent)" t-options='{"widget": "timesheet_uom"}'/> + </t> + <t t-else=""> + Total: <span t-esc="hours_spent" t-options='{"widget": "float_time"}'/> + </t> + </th> + </t> + </tr> + <tr t-else=""> + <div style="text-align: right;" class="mr-2 mb-1 text-muted"> + <t t-if="is_uom_day"> + Total: <span t-esc="timesheets[0]._convert_hours_to_days(hours_spent)" t-options='{"widget": "timesheet_uom"}'/> + </t> + <t t-else=""> + Total: <span t-esc="hours_spent" t-options='{"widget": "float_time"}'/> + </t> + </div> + </tr> + <tr> + <th t-if="not groupby == 'date'">Date</th> + <th t-if="not groupby == 'employee'">Employee</th> + <th t-if="not groupby == 'project'">Project</th> + <th t-if="not groupby == 'task'">Task</th> + <th>Description</th> + <th t-if="is_uom_day" class="text-right">Days Spent</th> + <th t-else="" class="text-right">Hours Spent</th> + </tr> + </thead> + <tbody style="font-size: 0.8rem"> + <t t-foreach="timesheets" t-as="timesheet"> + <tr> + <td t-if="not groupby == 'date'"><span t-field="timesheet.date" t-options='{"widget": "date"}'/></td> + <td t-if="not groupby == 'employee'"><span t-field="timesheet.employee_id" t-att-title="timesheet.employee_id.display_name" /></td> + <td t-if="not groupby == 'project'"><span t-field="timesheet.project_id" t-att-title="timesheet.project_id.display_name"/></td> + <td t-if="not groupby == 'task'"><span t-field="timesheet.task_id" t-att-title="timesheet.task_id.display_name"/></td> + <td><span t-esc="timesheet.name" t-att-title="timesheet.name"/></td> + <td class="text-right"> + <span t-if="is_uom_day" t-esc="timesheet._get_timesheet_time_day()" t-options='{"widget": "timesheet_uom"}'/> + <span t-else="" t-field="timesheet.unit_amount" t-options='{"widget": "float_time"}'/> + </td> + </tr> + </t> + </tbody> + </t> + </t> + </t> + </t> + </template> + +</odoo> diff --git a/addons/hr_timesheet/views/hr_timesheet_views.xml b/addons/hr_timesheet/views/hr_timesheet_views.xml new file mode 100644 index 00000000..d2b6f57a --- /dev/null +++ b/addons/hr_timesheet/views/hr_timesheet_views.xml @@ -0,0 +1,322 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data> + + <!-- Timesheet root menus --> + <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" sample="1"> + <field name="date"/> + <field name="employee_id" invisible="1"/> + <field name="project_id" required="1" options="{'no_create_edit': True}" context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/> + <field name="task_id" optional="show" options="{'no_create_edit': True, 'no_open': True}" widget="task_with_hours" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/> + <field name="name" optional="show" required="0"/> + <field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total" decoration-danger="unit_amount > 24"/> + <field name="company_id" invisible="1"/> + <field name="user_id" invisible="1"/> + </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='employee_id']" position="attributes"> + <attribute name="invisible">0</attribute> + <attribute name="required">1</attribute> + <attribute name="widget">many2one_avatar_employee</attribute> + </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> + <field name="arch" type="xml"> + <pivot string="Timesheet" sample="1"> + <field name="employee_id" type="row"/> + <field name="date" interval="month" type="col"/> + <field name="unit_amount" type="measure" widget="timesheet_uom"/> + <field name="amount" string="Timesheet Costs"/> + </pivot> + </field> + </record> + + <record id="view_hr_timesheet_line_graph" model="ir.ui.view"> + <field name="name">account.analytic.line.graph</field> + <field name="model">account.analytic.line</field> + <field name="arch" type="xml"> + <graph string="Timesheet" sample="1"> + <field name="task_id" type="row"/> + <field name="project_id" type="row"/> + <field name="unit_amount" type="measure" widget="timesheet_uom"/> + <field name="amount" string="Timesheet Costs"/> + </graph> + </field> + </record> + + <record id="hr_timesheet_line_form" model="ir.ui.view"> + <field name="name">account.analytic.line.form</field> + <field name="model">account.analytic.line</field> + <field name="priority">1</field> + <field name="inherit_id" eval="False"/> + <field name="arch" type="xml"> + <form string="Analytic Entry"> + <sheet string="Analytic Entry"> + <group> + <group> + <field name="date"/> + <field name="project_id" required="1" context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/> + <field name="task_id" widget="task_with_hours" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/> + <field name="name"/> + <field name="company_id" groups="base.group_multi_company"/> + </group> + <group> + <field name="amount"/> + <field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount > 24"/> + <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="employee_id" required="1" options='{"no_open": True}'/> + <field name="user_id" invisible="1"/> + </xpath> + </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> + <field name="arch" type="xml"> + <search string="Timesheet"> + <field name="date"/> + <field name="employee_id"/> + <field name="department_id"/> + <field name="project_id"/> + <field name="task_id"/> + <field name="name"/> + <filter name="mine" string="My Timesheets" domain="[('user_id', '=', uid)]"/> + <separator/> + <filter name="month" string="Date" date="date"/> + <group expand="0" string="Group By"> + <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="Date" name="groupby_date" domain="[]" context="{'group_by': 'date'}" help="Timesheet by Date"/> + <filter string="Department" name="groupby_department" domain="[]" context="{'group_by': 'department_id'}"/> + <filter string="Employee" name="groupby_employee" domain="[]" context="{'group_by': 'employee_id'}"/> + </group> + </search> + </field> + </record> + + <record id="hr_timesheet_line_my_timesheet_search" model="ir.ui.view"> + <field name="name">view.search.my.timesheet.menu</field> + <field name="model">account.analytic.line</field> + <field name="inherit_id" ref="hr_timesheet_line_search"/> + <field name="mode">primary</field> + <field name="arch" type="xml"> + <field name="employee_id" position="replace"/> + <field name="department_id" position="replace"/> + <filter name="mine" position="replace"/> + <filter name="groupby_department" position="replace"/> + <filter name="groupby_employee" position="replace"/> + </field> + </record> + + <record id="view_kanban_account_analytic_line" model="ir.ui.view"> + <field name="name">account.analytic.line.kanban</field> + <field name="model">account.analytic.line</field> + <field name="arch" type="xml"> + <kanban class="o_kanban_mobile" sample="1"> + <field name="date"/> + <field name="employee_id"/> + <field name="user_id"/> + <field name="name"/> + <field name="project_id"/> + <field name="task_id" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/> + <field name="unit_amount" widget="timesheet_uom"/> + <templates> + <t t-name="kanban-box"> + <div t-attf-class="oe_kanban_global_click"> + <div class="row"> + <div class="col-2"> + <img t-att-src="kanban_image('hr.employee', 'image_128', record.employee_id.raw_value)" t-att-title="record.employee_id.value" t-att-alt="record.employee_id.value" class="o_image_40_cover float-left"/> + </div> + <div class="col-10"> + <div> + <strong><t t-esc="record.project_id.value"/></strong> + </div> + <div class="text-muted"> + <span> + <t t-esc="record.name.value"/> + </span> + <div class="float-right" id="bottom_right"/> + </div> + </div> + </div> + <hr class="mt4 mb4"/> + <span> + <i class="fa fa-calendar" role="img" aria-label="Date" title="Date"></i> + <t t-esc="record.date.value"/> + </span> + <span class="float-right"> + <strong>Duration: </strong><field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount > 24"/> + </span> + </div> + </t> + </templates> + </kanban> + </field> + </record> + + <!-- + Menus and Actions + --> + <record id="act_hr_timesheet_line" model="ir.actions.act_window"> + <field name="name">My Timesheets</field> + <field name="res_model">account.analytic.line</field> + <field name="view_mode">tree,form,kanban</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_my_timesheet_search"/> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + No activities found. Let's start a new one! + </p> + <p> + Track your working hours by projects every day and invoice this time to your customers. + </p> + </field> + </record> + + <record id="act_hr_timesheet_line_view_tree" model="ir.actions.act_window.view"> + <field name="view_mode">tree</field> + <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 id="act_hr_timesheet_line_view_form" model="ir.actions.act_window.view"> + <field name="view_mode">form</field> + <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> + + <record id="act_hr_timesheet_line_view_kanban" model="ir.actions.act_window.view"> + <field name="view_mode">kanban</field> + <field name="sequence">6</field> + <field name="view_id" ref="hr_timesheet.view_kanban_account_analytic_line"/> + <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_task" model="ir.actions.act_window"> + <field name="name">Task's Timesheets</field> + <field name="res_model">account.analytic.line</field> + <field name="domain">[('task_id', 'in', active_ids)]</field> + <field name="view_mode">tree</field> + <field name="view_id" ref="timesheet_view_tree_user"/> + </record> + + <record id="timesheet_action_project" model="ir.actions.act_window"> + <field name="name">Project's Timesheets</field> + <field name="res_model">account.analytic.line</field> + <field name="domain">[('project_id', 'in', active_ids)]</field> + <field name="view_mode">tree</field> + <field name="view_id" ref="timesheet_view_tree_user"/> + </record> + + <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="view_mode">tree,form,pivot,kanban</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, + }</field> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + No activities found. Let's start a new one! + </p> + <p> + Track your working hours by projects every day and invoice this time to your customers. + </p> + </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_pivot" model="ir.actions.act_window.view"> + <field name="sequence" eval="6"/> + <field name="view_mode">pivot</field> + <field name="view_id" ref="view_hr_timesheet_line_pivot"/> + <field name="act_window_id" ref="timesheet_action_all"/> + </record> + + <record id="timesheet_action_view_all_kanban" model="ir.actions.act_window.view"> + <field name="view_mode">kanban</field> + <field name="sequence">7</field> + <field name="view_id" ref="hr_timesheet.view_kanban_account_analytic_line"/> + <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" + groups="hr_timesheet.group_hr_timesheet_approver"/> + + </data> +</odoo> diff --git a/addons/hr_timesheet/views/hr_views.xml b/addons/hr_timesheet/views/hr_views.xml new file mode 100644 index 00000000..19aaf29b --- /dev/null +++ b/addons/hr_timesheet/views/hr_views.xml @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <record id="timesheet_action_from_employee" model="ir.actions.act_window"> + <field name="name">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_month':1, + 'search_default_employee_id': [active_id], + 'default_employee_id': active_id + }</field> + </record> + + <record id="timesheet_action_view_from_employee_list" model="ir.actions.act_window.view"> + <field name="sequence" eval="5"/> + <field name="view_mode">tree</field> + <field name="view_id" ref="hr_timesheet_line_tree"/> + <field name="act_window_id" ref="timesheet_action_from_employee"/> + </record> + + <record id="timesheet_action_view_from_employee_form" model="ir.actions.act_window.view"> + <field name="sequence" eval="10"/> + <field name="view_mode">form</field> + <field name="view_id" ref="hr_timesheet_line_form"/> + <field name="act_window_id" ref="timesheet_action_from_employee"/> + </record> + + <record id="hr_employee_view_form_inherit_timesheet" model="ir.ui.view"> + <field name="name">hr.employee.form.timesheet</field> + <field name="model">hr.employee</field> + <field name="inherit_id" ref="hr.view_employee_form"/> + <field name="arch" type="xml"> + <xpath expr="//page[@name='hr_settings']" position="inside"> + <group> + <group string="Timesheets" name="timesheet" groups="hr_timesheet.group_timesheet_manager"> + <label for="timesheet_cost"/> + <div> + <field name="timesheet_cost" class="oe_inline"/> per hour + <field name="currency_id" invisible="1"/> + </div> + </group> + </group> + </xpath> + <div name="button_box" position="inside"> + <button class="oe_stat_button" type="action" name="%(timesheet_action_from_employee)d" icon="fa-calendar" groups="hr_timesheet.group_hr_timesheet_user"> + <div class="o_stat_info"> + <span class="o_stat_text">Timesheets</span> + </div> + </button> + </div> + </field> + </record> + + <record id="hr_department_view_kanban" model="ir.ui.view"> + <field name="name">hr.department.kanban.inherit</field> + <field name="model">hr.department</field> + <field name="inherit_id" ref="hr.hr_department_view_kanban"/> + <field name="groups_id" eval="[(4,ref('hr_timesheet.group_timesheet_manager'))]"/> + <field name="arch" type="xml"> + <data> + <xpath expr="//div[hasclass('o_kanban_manage_reports')]" position="inside"> + <a name="%(act_hr_timesheet_report)d" type="action" context="{ 'search_default_department_id': [active_id], 'default_department_id': active_id}"> + Timesheets + </a> + </xpath> + </data> + </field> + </record> +</odoo> diff --git a/addons/hr_timesheet/views/project_portal_templates.xml b/addons/hr_timesheet/views/project_portal_templates.xml new file mode 100644 index 00000000..8f6a10e8 --- /dev/null +++ b/addons/hr_timesheet/views/project_portal_templates.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + + <template id="portal_my_task" inherit_id="project.portal_my_task" name="Portal: My Task with Timesheets"> + <xpath expr="//t[@t-set='card_body']" position="inside"> + <div class="container" t-if="timesheets"> + <hr class="mt-4 mb-1"/> + <h5 class="mt-2 mb-2">Timesheets</h5> + <t t-call="hr_timesheet.portal_timesheet_table"/> + </div> + <t t-if="timesheets_by_subtask"> + <t t-call="hr_timesheet.portal_subtask_timesheet_tables"/> + </t> + </xpath> + </template> + + <template id="portal_timesheet_table" name="Portal Timesheet Table"> + <table class="table table-sm"> + <thead> + <tr> + <th>Date</th> + <th>Employee</th> + <th>Description</th> + <th t-if="is_uom_day" class="text-right">Duration (Days)</th> + <th t-else="" class="text-right">Duration (Hours)</th> + </tr> + </thead> + <tr t-foreach="timesheets" t-as="timesheet"> + <td><t t-esc="timesheet.date" t-options='{"widget": "date"}'/></td> + <td><t t-esc="timesheet.employee_id.name"/></td> + <td><t t-esc="timesheet.name"/></td> + <td class="text-right"> + <span t-if="is_uom_day" t-esc="timesheet._get_timesheet_time_day()" t-options='{"widget": "timesheet_uom"}'/> + <span t-else="" t-field="timesheet.unit_amount" t-options='{"widget": "float_time"}'/> + </td> + </tr> + <tfoot> + <tr> + <th colspan="3"></th> + <th class="text-right">Total Hours: <span t-esc="round(sum(timesheets.mapped('unit_amount')), 2)" t-options='{"widget": "float_time"}'/></th> + </tr> + </tfoot> + </table> + </template> + + <template id="portal_subtask_timesheet_tables" name="Portal Subtask Timesheet Tables"> + <t t-foreach="timesheets_by_subtask.values()" t-as="timesheets"> + <t t-set="total_hours" t-value="round(sum(timesheets.mapped('unit_amount')), 2)"/> + <t t-if="total_hours > 0"> + <div class="container"> + <hr class="mt-4 mb-1"/> + <h5 class="mt-2 mb-2">Timesheets for sub-task: <t t-esc="timesheets[0].task_id.name" /></h5> + <table class="table table-sm"> + <thead> + <tr> + <th>Date</th> + <th>Employee</th> + <th>Description</th> + <th class="text-right">Duration</th> + </tr> + </thead> + <tr t-foreach="timesheets" t-as="timesheet"> + <td><t t-esc="timesheet.date" t-options='{"widget": "date"}'/></td> + <td><t t-esc="timesheet.employee_id.name"/></td> + <td><t t-esc="timesheet.name"/></td> + <td class="text-right"><span t-field="timesheet.unit_amount" t-options='{"widget": "float_time"}'/></td> + </tr> + <tfoot> + <tr> + <th class="text-right" colspan="3"></th> + <th class="text-right">Total Hours: <span t-esc="total_hours" t-options='{"widget": "float_time"}'/></th> + </tr> + </tfoot> + </table> + </div> + </t> + </t> + </template> + +</odoo> diff --git a/addons/hr_timesheet/views/project_views.xml b/addons/hr_timesheet/views/project_views.xml new file mode 100644 index 00000000..9d2fc6a4 --- /dev/null +++ b/addons/hr_timesheet/views/project_views.xml @@ -0,0 +1,281 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data> + <record id="act_hr_timesheet_line_by_project" model="ir.actions.act_window"> + <field name="name">Timesheets</field> + <field name="res_model">account.analytic.line</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="timesheet_view_tree_user"/> + <field name="domain">[('project_id', '!=', False)]</field> + <field name="context">{"default_project_id": active_id, "search_default_project_id": [active_id]}</field> + <field name="search_view_id" ref="hr_timesheet_line_search"/> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + Record a new activity + </p><p> + Track your working hours by projects every day and invoice this time to your customers. + </p> + </field> + </record> + + <record id="project_project_view_form_simplified_inherit_timesheet" model="ir.ui.view"> + <field name="name">project.project.view.form.simplified.inherit.timesheet</field> + <field name="model">project.project</field> + <field name="inherit_id" ref="project.project_project_view_form_simplified"/> + <field name="priority">24</field> + <field name="arch" type="xml"> + <field name="user_id" position="after"> + <field name="allow_timesheets"/> + </field> + </field> + </record> + + <record id="project_invoice_form" model="ir.ui.view"> + <field name="name">Inherit project form : Invoicing Data</field> + <field name="model">project.project</field> + <field name="inherit_id" ref="project.edit_project"/> + <field name="priority">24</field> + <field name="arch" type="xml"> + <div name="button_box" position="inside"> + <button class="oe_stat_button" name="%(act_hr_timesheet_line_by_project)d" type="action" icon="fa-calendar" attrs="{'invisible': [('allow_timesheets', '=', False)]}" groups="hr_timesheet.group_hr_timesheet_user"> + <div class="o_field_widget o_stat_info"> + <div class="oe_inline"> + <span class="o_stat_value mr-1"> + <field name="total_timesheet_time" widget="statinfo" nolabel="1"/> + </span> + <span class="o_stat_value"> + <field name="timesheet_encode_uom_id" class="o_stat_text" options="{'no_open' : True}"/> + </span> + </div> + <span class="o_stat_text">Recorded</span> + </div> + </button> + </div> + <xpath expr="//div[@id='rating_settings']/.." position="before"> + <div class="row mt16 o_settings_container"> + <div class="col-lg-6 o_setting_box" id="timesheet_settings"> + <div class="o_setting_left_pane"> + <field name="allow_timesheets"/> + </div> + <div class="o_setting_right_pane"> + <label for="allow_timesheets" string="Timesheets"/> + <div class="text-muted"> + Log time on tasks + </div> + </div> + </div> + </div> + </xpath> + </field> + </record> + + <record model="ir.ui.view" id="view_task_form2_inherited"> + <field name="name">project.task.form.inherited</field> + <field name="model">project.task</field> + <field name="inherit_id" ref="project.view_task_form2" /> + <field name="groups_id" eval="[(6,0, (ref('hr_timesheet.group_hr_timesheet_user'),))]"/> + <field name="arch" type="xml"> + <xpath expr="//notebook/page[@name='description_page']" position="after"> + <field name="analytic_account_active" invisible="1"/> + <field name="allow_timesheets" invisible="1"/> + <field name="allow_subtasks" invisible="1"/> + <field name="encode_uom_in_days" invisible="1"/> + <page string="Timesheets" id="timesheets_tab" attrs="{'invisible': [('allow_timesheets', '=', False)]}"> + <group> + <group> + <div class="o_td_label"> + <label for="planned_hours" string="Initially Planned Hours" attrs="{'invisible': [('encode_uom_in_days', '=', True)]}"/> + <label for="planned_hours" string="Initially Planned Days" attrs="{'invisible': [('encode_uom_in_days', '=', False)]}"/> + </div> + <field name="planned_hours" widget="timesheet_uom_no_toggle" nolabel="1"/> + <div class="o_td_label" groups="project.group_subtask_project" attrs="{'invisible': ['|', ('allow_subtasks', '=', False), ('subtask_count', '=', 0)]}"> + <label for="subtask_planned_hours" string="Sub-tasks Planned Hours" attrs="{'invisible': [('encode_uom_in_days', '=', True)]}"/> + <label for="subtask_planned_hours" string="Sub-tasks Planned Days" attrs="{'invisible': [('encode_uom_in_days', '=', False)]}"/> + </div> + <field name="subtask_planned_hours" widget="timesheet_uom_no_toggle" nolabel="1" groups="project.group_subtask_project" attrs="{'invisible': ['|', ('allow_subtasks', '=', False), ('subtask_count', '=', 0)]}"/> + </group> + <group> + <field name="progress" widget="progressbar"/> + </group> + </group> + <group name="timesheet_error" attrs="{'invisible': [('analytic_account_active', '!=', False)]}"> + <div class="alert alert-warning" role="alert"> + You cannot log timesheets on this project since it is linked to an inactive analytic account. Please change this account, or reactivate the current one to timesheet on the project. + </div> + </group> + <field name="timesheet_ids" mode="tree,kanban" attrs="{'invisible': [('analytic_account_active', '=', False)]}" context="{'default_project_id': project_id, 'default_name':''}"> + <tree editable="bottom" string="Timesheet Activities" default_order="date"> + <field name="date"/> + <field name="user_id" invisible="1"/> + <field name="employee_id" required="1" widget="many2one_avatar_employee"/> + <field name="name" required="0"/> + <field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount > 24"/> + <field name="project_id" invisible="1"/> + <field name="task_id" invisible="1"/> + <field name="company_id" invisible="1"/> + </tree> + <kanban class="o_kanban_mobile"> + <field name="date"/> + <field name="user_id"/> + <field name="employee_id" widget="many2one_avatar_employee"/> + <field name="name"/> + <field name="unit_amount" decoration-danger="unit_amount > 24"/> + <field name="project_id"/> + <field name="task_id" invisible="1"/> + <templates> + <t t-name="kanban-box"> + <div t-attf-class="oe_kanban_card oe_kanban_global_click"> + <div class="row"> + <div class="col-6"> + <strong><span><t t-esc="record.employee_id.value"/></span></strong> + </div> + <div class="col-6 pull-right text-right"> + <strong><t t-esc="record.date.value"/></strong> + </div> + </div> + <div class="row"> + <div class="col-6 text-muted"> + <span><t t-esc="record.name.value"/></span> + </div> + <div class="col-6"> + <span class="pull-right text-right"> + <field name="unit_amount" widget="float_time"/> + </span> + </div> + </div> + </div> + </t> + </templates> + </kanban> + <form string="Timesheet Activities"> + <sheet> + <group> + <field name="date"/> + <field name="user_id" invisible="1"/> + <field name="employee_id" required="1" widget="many2one_avatar_employee"/> + <field name="name"/> + <field name="unit_amount" string="Duration" widget="float_time" decoration-danger="unit_amount > 24"/> + <field name="project_id" invisible="1"/> + <field name="task_id" invisible="1"/> + <field name="company_id" invisible="1"/> + </group> + </sheet> + </form> + </field> + <group attrs="{'invisible': [('analytic_account_active', '=', False)]}"> + <group class="oe_subtotal_footer oe_right" name="project_hours"> + <span> + <label class="font-weight-bold" for="effective_hours" string="Hours Spent" attrs="{'invisible': [('encode_uom_in_days', '=', True)]}"/> + <label class="font-weight-bold" for="effective_hours" string="Days Spent" attrs="{'invisible': [('encode_uom_in_days', '=', False)]}"/> + </span> + <field name="effective_hours" widget="timesheet_uom" nolabel="1"/> + + <button name="action_view_subtask_timesheet" type="object" class="o_td_label o_form_label o_form_subtask_button oe_inline oe_link mr-0" attrs="{'invisible' : ['|', ('allow_subtasks', '=', False), ('subtask_effective_hours', '=', 0.0)]}"> + <span class="text-nowrap" attrs="{'invisible' : [('encode_uom_in_days', '=', True)]}">Sub-tasks Hours Spent</span> + <span class="text-nowrap" attrs="{'invisible' : [('encode_uom_in_days', '=', False)]}">Sub-tasks Days Spent</span> + </button> + <field name="subtask_effective_hours" class="mt-2" widget="timesheet_uom" + attrs="{'invisible' : ['|', ('allow_subtasks', '=', False), ('subtask_effective_hours', '=', 0.0)]}" nolabel="1"/> + <span> + <label class="font-weight-bold" for="total_hours_spent" string="Total Hours" + attrs="{'invisible': ['|', '|', ('allow_subtasks', '=', False), ('subtask_effective_hours', '=', 0.0), ('encode_uom_in_days', '=', True)]}"/> + <label class="font-weight-bold" for="total_hours_spent" string="Total Days" + attrs="{'invisible': ['|', '|', ('allow_subtasks', '=', False), ('subtask_effective_hours', '=', 0.0), ('encode_uom_in_days', '=', False)]}"/> + </span> + <field name="total_hours_spent" widget="timesheet_uom" class="oe_subtotal_footer_separator" nolabel="1" + attrs="{'invisible' : ['|', ('allow_subtasks', '=', False), ('subtask_effective_hours', '=', 0.0)]}" /> + <span> + <label class="font-weight-bold" for="remaining_hours" string="Remaining Hours" + attrs="{'invisible': ['|', ('planned_hours', '=', 0.0), ('encode_uom_in_days', '=', True)]}"/> + <label class="font-weight-bold" for="remaining_hours" string="Remaining Days" + attrs="{'invisible': ['|', ('planned_hours', '=', 0.0), ('encode_uom_in_days', '=', False)]}"/> + </span> + <field name="remaining_hours" widget="timesheet_uom" class="oe_subtotal_footer_separator" + attrs="{'invisible' : [('planned_hours', '=', 0.0)]}" nolabel="1"/> + </group> + </group> + </page> + </xpath> + </field> + </record> + + <record id="view_task_tree2_inherited" model="ir.ui.view"> + <field name="name">project.task.tree.inherited</field> + <field name="model">project.task</field> + <field name="inherit_id" ref="project.view_task_tree2" /> + <field eval="2" name="priority"/> + <field name="arch" type="xml"> + <field name="company_id" position="after"> + <field name="allow_subtasks" invisible="1"/> + <field name="planned_hours" widget="timesheet_uom_no_toggle" sum="Initially Planned Hours" optional="hide"/> + <field name="effective_hours" widget="timesheet_uom" sum="Effective Hours" optional="show"/> + <field name="remaining_hours" widget="timesheet_uom" sum="Remaining Hours" optional="hide" decoration-danger="progress >= 100" decoration-warning="progress >= 80 and progress < 100"/> + <field name="subtask_effective_hours" widget="timesheet_uom" attrs="{'invisible' : [('allow_subtasks', '=', False)]}" optional="hide"/> + <field name="total_hours_spent" widget="timesheet_uom" attrs="{'invisible' : [('allow_subtasks', '=', False)]}" optional="hide"/> + <field name="progress" widget="progressbar" optional="show" groups="hr_timesheet.group_hr_timesheet_user"/> + </field> + </field> + </record> + + <record id="view_project_kanban_inherited" model="ir.ui.view"> + <field name="name">project.project.timesheet.kanban.inherited</field> + <field name="model">project.project</field> + <field name="inherit_id" ref="project.view_project_kanban"/> + <field name="priority">24</field> + <field name="arch" type="xml"> + <field name="partner_id" position="after"> + <field name="allow_timesheets" invisible="1"/> + </field> + <xpath expr="//div[hasclass('o_project_kanban_boxes')]" position="inside"> + <a t-if="record.allow_timesheets.raw_value" class="o_project_kanban_box o_project_timesheet_box" name="%(act_hr_timesheet_line_by_project)d" type="action" groups="hr_timesheet.group_hr_timesheet_user"> + <div> + <span class="o_label">Timesheets</span> + </div> + </a> + </xpath> + <xpath expr="//a[@name='action_view_account_analytic_line']" position="attributes"> + <attribute name="t-if">record.analytic_account_id.raw_value and !record.allow_timesheets.raw_value</attribute> + </xpath> + </field> + </record> + + <record id="view_task_kanban_inherited_progress" model="ir.ui.view"> + <field name="name">project.task.timesheet.kanban.inherited.progress</field> + <field name="model">project.task</field> + <field name="inherit_id" ref="project.view_task_kanban"/> + <field name="arch" type="xml"> + <templates position="before"> + <field name="progress" /> + <field name="remaining_hours" /> + <field name="planned_hours" /> + <field name="allow_timesheets"/> + <field name="encode_uom_in_days" invisible="1"/> + </templates> + <div class="oe_kanban_bottom_left" position="inside"> + <t name="planned_hours" t-if="record.planned_hours.raw_value > 0 and record.allow_timesheets.raw_value"> + <t t-set="badge" t-value=""/> + <t t-set="badge" t-value="'badge-warning'" t-if="record.progress.raw_value >= 80 and record.progress.raw_value <= 100"/> + <t t-set="badge" t-value="'badge-danger'" t-if="record.remaining_hours.raw_value < 0"/> + <t t-set="title" t-value="'Remaining days'" t-if="record.encode_uom_in_days.raw_value"/> + <t t-set="title" t-value="'Remaining hours'" t-else=""/> + <div t-attf-class="oe_kanban_align badge {{ badge }}" t-att-title="title"> + <field name="remaining_hours" widget="timesheet_uom" /> + </div> + </t> + </div> + </field> + </record> + + <record id="project_task_view_search" model="ir.ui.view"> + <field name="name">project.task.view.search.inherit.sale.timesheet.enterprise</field> + <field name="model">project.task</field> + <field name="inherit_id" ref="project.view_task_search_form"/> + <field name="arch" type="xml"> + <xpath expr="//filter[@name='late']" position='after'> + <filter string="Tasks in Overtime" name="overtime" domain="[('overtime', '>', 0)]"/> + </xpath> + </field> + </record> + + </data> +</odoo> diff --git a/addons/hr_timesheet/views/res_config_settings_views.xml b/addons/hr_timesheet/views/res_config_settings_views.xml new file mode 100644 index 00000000..038fd26c --- /dev/null +++ b/addons/hr_timesheet/views/res_config_settings_views.xml @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<odoo> + <menuitem id="hr_timesheet_menu_configuration" name="Configuration" parent="timesheet_menu_root" + groups="group_timesheet_manager" sequence="100"/> + + <record id="res_config_settings_view_form" model="ir.ui.view"> + <field name="name">res.config.settings.view.form.inherit.hr.timesheet</field> + <field name="model">res.config.settings</field> + <field name="priority" eval="55"/> + <field name="inherit_id" ref="base.res_config_settings_view_form"/> + <field name="arch" type="xml"> + <xpath expr="//form" position="attributes"> + <attribute name="js_class">hr_timesheet_config_form</attribute> + </xpath> + <xpath expr="//div[hasclass('settings')]" position="inside"> + <div class="app_settings_block" data-string="Timesheets" string="Timesheets" data-key="hr_timesheet" groups="hr_timesheet.group_timesheet_manager" id="timesheets"> + <h2>Time Encoding</h2> + <div class="row mt16 o_settings_container" name="time_encoding_setting_container"> + <div class="col-12 col-lg-6 o_setting_box" + id="time_mode_setting" + attrs="{'invisible':[('project_time_mode_id', '!=', False)]}"> + <div class="o_setting_right_pane"> + <label for="project_time_mode_id"/> + <span class="fa fa-lg fa-building-o" title="Values set here are company-specific." groups="base.group_multi_company"/> + <div class="content-group"> + <div class="mt16"> + <field name="project_time_mode_id" options="{'no_create': True, 'no_open': True}"/> + </div> + </div> + </div> + </div> + <div class="col-12 col-lg-6 o_setting_box" id="time_unit_timesheets_setting"> + <div class="o_setting_right_pane"> + <label for="timesheet_encode_uom_id"/> + <span class="fa fa-lg fa-building-o" title="Values set here are company-specific." groups="base.group_multi_company"/> + <div class="row"> + <div class="text-muted col-md-12"> + Time unit used to record your timesheets + </div> + </div> + <div class="content-group"> + <div class="mt16"> + <field name="timesheet_encode_uom_id" options="{'no_create': True, 'no_open': True}" required="1" class="col-lg-5"/> + <field name="is_encode_uom_days" invisible="1"/> + </div> + </div> + </div> + </div> + <div class="col-12 col-lg-6 o_setting_box" id="synchronize_web_mobile_setting"> + <div class="o_setting_left_pane"> + <field name="module_project_timesheet_synchro" widget="upgrade_boolean"/> + </div> + <div style="width:130%" class="o_setting_right_pane"> + <label for="module_project_timesheet_synchro"/> + <div class="text-muted"> + Track your time from anywhere, even offline, with our web/mobile apps + </div> + <div class="content-group"> + <div class="row mt16 oe_center"> + <div class="col-lg-3 pr-0 o_chrome_store_link d-none d-sm-inline-block"> + <a href="http://www.odoo.com/page/timesheet?platform=chrome" class="align-middle" target="_blank"> + <img alt="Google Chrome Store" class="img img-fluid align-middle mt-1" style="height: 85% !important;" src="project/static/src/img/chrome_store.png"/> + </a> + </div> + <div class="col-lg-3 pr-0"> + <img alt="Apple App Store" class="img img-fluid o_config_app_store mt-1" style="height: 85% !important; cursor: pointer;" src="project/static/src/img/app_store.png"/> + </div> + <div class="col-lg-3 pr-0"> + <img alt="Google Play Store" class="img img-fluid o_config_play_store mt-1" style="height: 85% !important; cursor: pointer;" src="project/static/src/img/play_store.png"/> + </div> + </div> + </div> + </div> + </div> + <div class="col-12 col-lg-6 o_setting_box" attrs="{'invisible': [('module_project_timesheet_synchro', '=', False), ('is_encode_uom_days', '=', True)]}"> + <div class="o_setting_right_pane"> + <strong>Round Timesheets</strong> + <div class="o_row w-30"> + <span class="o_light_label"><label for="timesheet_min_duration"/><field name="timesheet_min_duration" class="col-lg-2"/> minutes</span> + </div> + <div class="o_row"> + <span class="o_light_label"><label for="timesheet_rounding"/><field name="timesheet_rounding" class="col-lg-2"/> minutes</span> + </div> + </div> + </div> + </div> + <div name="section_leaves" groups="base.group_no_one"> + <h2>Time Off</h2> + <div class="row mt16 o_settings_container" name="timesheet_control"> + <div class="col-12 col-lg-6 o_setting_box" id="timesheet_off_validation_setting"> + <div class="o_setting_left_pane"> + <field name="module_project_timesheet_holidays"/> + </div> + <div class="o_setting_right_pane"> + <label for="module_project_timesheet_holidays"/> + <span class="fa fa-lg fa-building-o" title="Values set here are company-specific." groups="base.group_multi_company"/> + <div class="text-muted"> + Create timesheets upon time off validation + </div> + <div class="content-group"> + <div id="module_project_timesheet_holidays"/> + </div> + </div> + </div> + </div> + </div> + </div> + </xpath> + </field> + </record> + + <record id="hr_timesheet_config_settings_action" model="ir.actions.act_window"> + <field name="name">Settings</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">res.config.settings</field> + <field name="view_mode">form</field> + <field name="target">inline</field> + <field name="context">{'module' : 'hr_timesheet', 'bin_size': False}</field> + </record> + + <menuitem id="hr_timesheet_config_settings_menu_action" name="Settings" parent="hr_timesheet_menu_configuration" + action="hr_timesheet_config_settings_action" sequence="0" groups="base.group_system"/> +</odoo> |
