[IMP] hr_timesheet: Improve general module UX (back2basics)

TaskID: 2025197

closes odoo/odoo#34855

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
RomainLibert
2019-07-16 12:03:42 +00:00
committed by Yannick Tivisse
parent 22221a2b57
commit 02c48e71f0
6 changed files with 62 additions and 10 deletions
@@ -14,6 +14,8 @@ class AccountAnalyticLine(models.Model):
@api.model
def default_get(self, field_list):
result = super(AccountAnalyticLine, self).default_get(field_list)
if 'encoding_uom_id' in field_list:
result['encoding_uom_id'] = self.env.company.timesheet_encode_uom_id.id
if not self.env.context.get('default_employee_id') and 'employee_id' in field_list and result.get('user_id'):
result['employee_id'] = self.env['hr.employee'].search([('user_id', '=', result['user_id'])], limit=1).id
return result
@@ -23,6 +25,11 @@ class AccountAnalyticLine(models.Model):
employee_id = fields.Many2one('hr.employee', "Employee")
department_id = fields.Many2one('hr.department', "Department", compute='_compute_department_id', store=True, compute_sudo=True)
encoding_uom_id = fields.Many2one('uom.uom', compute='_compute_encoding_uom_id')
def _compute_encoding_uom_id(self):
for analytic_line in self:
analytic_line.encoding_uom_id = self.env.company.timesheet_encode_uom_id
@api.onchange('project_id')
def onchange_project_id(self):
@@ -2,7 +2,7 @@
<odoo>
<data>
<record id="act_hr_timesheet_report" model="ir.actions.act_window">
<field name="name">By Employee</field>
<field name="name">Timesheets By Employee</field>
<field name="res_model">account.analytic.line</field>
<field name="domain">[('project_id', '!=', False)]</field>
<field name="context">{'search_default_groupby_employee':1,}</field>
@@ -25,6 +25,13 @@
<field name="act_window_id" ref="act_hr_timesheet_report"/>
</record>
<record id="timesheet_action_view_report_by_employee_graph" model="ir.actions.act_window.view">
<field name="sequence" eval="6"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="hr_timesheet.view_hr_timesheet_line_graph"/>
<field name="act_window_id" ref="act_hr_timesheet_report"/>
</record>
<record model="ir.actions.act_window.view" id="act_hr_timesheet_report_tree">
<field name="sequence" eval="10"/>
<field name="view_mode">tree</field>
@@ -40,7 +47,7 @@
</record>
<record id="timesheet_action_report_by_project" model="ir.actions.act_window">
<field name="name">By Project</field>
<field name="name">Timesheets By Project</field>
<field name="res_model">account.analytic.line</field>
<field name="domain">[('project_id', '!=', False)]</field>
<field name="context">{'search_default_groupby_project':1,}</field>
@@ -63,6 +70,13 @@
<field name="act_window_id" ref="timesheet_action_report_by_project"/>
</record>
<record id="timesheet_action_view_report_by_project_graph" model="ir.actions.act_window.view">
<field name="sequence" eval="6"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="hr_timesheet.view_hr_timesheet_line_graph"/>
<field name="act_window_id" ref="timesheet_action_report_by_project"/>
</record>
<record id="timesheet_action_view_report_by_project_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="10"/>
<field name="view_mode">tree</field>
@@ -78,10 +92,10 @@
</record>
<record id="timesheet_action_report_by_task" model="ir.actions.act_window">
<field name="name">By Task</field>
<field name="name">Timesheets By Task</field>
<field name="res_model">account.analytic.line</field>
<field name="domain">[('project_id', '!=', False)]</field>
<field name="context">{'search_default_groupby_task':1,}</field>
<field name="context">{'search_default_groupby_project':1,'search_default_groupby_task':1,}</field>
<field name="search_view_id" ref="hr_timesheet_line_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
@@ -101,6 +115,13 @@
<field name="act_window_id" ref="timesheet_action_report_by_task"/>
</record>
<record id="timesheet_action_view_report_by_task_graph" model="ir.actions.act_window.view">
<field name="sequence" eval="6"/>
<field name="view_mode">graph</field>
<field name="view_id" ref="hr_timesheet.view_hr_timesheet_line_graph"/>
<field name="act_window_id" ref="timesheet_action_report_by_task"/>
</record>
<record id="timesheet_action_view_report_by_task_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="10"/>
<field name="view_mode">tree</field>
@@ -122,7 +143,7 @@
sequence="99"/>
<menuitem id="menu_timesheets_reports_timesheet"
name="Timesheet"
name="Timesheets"
parent="menu_timesheets_reports"
groups="hr_timesheet.group_timesheet_manager"
sequence="10"/>
@@ -24,7 +24,7 @@
<tree editable="top" string="Timesheet Activities" import="false">
<field name="date"/>
<field name="name"/>
<field name="project_id" required="1"/>
<field name="project_id" required="1" context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
<field name="task_id" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/>
<field name="unit_amount" widget="timesheet_uom" sum="Total"/>
</tree>
@@ -57,6 +57,18 @@
</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">
<field name="task_id" type="row"/>
<field name="project_id" type="row"/>
<field name="unit_amount" type="measure" widget="timesheet_uom"/>
</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>
@@ -68,7 +80,7 @@
<group>
<group>
<field name="date"/>
<field name="project_id" required="1"/>
<field name="project_id" required="1" context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
<field name="task_id"/>
<field name="name"/>
<field name="company_id" groups="base.group_multi_company"/>
+13 -2
View File
@@ -265,11 +265,22 @@
</div>
</group>
</group>
</form>
</field>
</record>
<record id="project_project_view_form_simplified_footer" model="ir.ui.view">
<field name="name">project.project.view.form.simplified</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.project_project_view_form_simplified"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//group" position="after">
<footer>
<button string="Create" name="open_tasks" type="object" class="btn-primary o_open_tasks"/>
<button string="Discard" class="btn-secondary" special="cancel"/>
</footer>
</form>
</xpath>
</field>
</record>
@@ -277,7 +288,7 @@
<field name="name">Create a Project</field>
<field name="res_model">project.project</field>
<field name="view_mode">form</field>
<field name="view_id" ref="project_project_view_form_simplified"/>
<field name="view_id" ref="project_project_view_form_simplified_footer"/>
<field name="target">new</field>
</record>
@@ -33,7 +33,7 @@
Reporting
-->
<record id="timesheet_action_billing_report" model="ir.actions.act_window">
<field name="name">By Billing Rate</field>
<field name="name">Timesheets By Billing Rate</field>
<field name="res_model">account.analytic.line</field>
<field name="view_mode">pivot,graph</field>
<field name="domain">[('project_id', '!=', False)]</field>
+1
View File
@@ -52,6 +52,7 @@
<field name="factor" eval="1000"/>
<field name="uom_type">smaller</field>
</record>
<record id="product_uom_day" model="uom.uom">
<field name="name">Days</field>
<field eval="uom_categ_wtime" name="category_id"/>