[IMP] {hr,sale}_timesheet{,_attendance}: improve generic UX

Purpose of this commit is to do generic UX.

So, in this commit done following points:
 - improve search on invoice for portal commit when invoice is in
   draft then search on id of invoice instead of name.
 - display unit_amount field in muted when value of unit_amount
   is equal to 0.
 - rename timesheet attendance report.

task-2969791

closes odoo/odoo#100141

Related: odoo/upgrade#3897
Related: odoo/enterprise#31304
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
Kartik Chavda
2023-04-03 17:07:07 +02:00
parent fdb692c25b
commit cb12ab2f1c
4 changed files with 11 additions and 22 deletions
@@ -12,7 +12,8 @@
<field name="project_id" required="1" options="{'no_create_edit': True, 'no_open': 1}" attrs="{'readonly': [('readonly_timesheet', '=', True)]}"/>
<field name="task_id" optional="show" options="{'no_create_edit': True, 'no_open': True}" widget="task_with_hours" context="{'default_project_id': project_id}" attrs="{'readonly': [('readonly_timesheet', '=', True)]}"/>
<field name="name" optional="show" required="0" attrs="{'readonly': [('readonly_timesheet', '=', True)]}"/>
<field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total" decoration-danger="unit_amount &gt; 24 or unit_amount &lt; 0" attrs="{'readonly': [('readonly_timesheet', '=', True)]}"/>
<field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total" attrs="{'readonly': [('readonly_timesheet', '=', True)]}"
decoration-danger="unit_amount &gt; 24 or unit_amount &lt; 0" decoration-muted="unit_amount == 0"/>
<field name="company_id" invisible="1"/>
<field name="user_id" invisible="1"/>
</tree>
@@ -132,7 +133,7 @@
<field name="date" attrs="{'readonly': [('readonly_timesheet', '=', True)]}"/>
<field name="amount" invisible="1"/>
<field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount &gt; 24"
attrs="{'readonly': [('readonly_timesheet', '=', True)]}"/>
attrs="{'readonly': [('readonly_timesheet', '=', True)]}" decoration-muted="unit_amount == 0"/>
<field name="currency_id" invisible="1"/>
<field name="company_id" invisible="1"/>
</group>
@@ -251,7 +252,7 @@
<t t-esc="record.date.value"/>
</span>
<span class="float-end" name="duration">
<strong>Duration: </strong><field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount &gt; 24"/>
<strong>Duration: </strong><field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount &gt; 24" decoration-muted="unit_amount == 0"/>
</span>
</div>
</div>
@@ -268,7 +269,7 @@
<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,pivot,graph</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,
@@ -306,20 +307,6 @@
<field name="act_window_id" ref="act_hr_timesheet_line"/>
</record>
<record id="act_hr_timesheet_line_view_pivot" model="ir.actions.act_window.view">
<field name="view_mode">pivot</field>
<field name="sequence">7</field>
<field name="view_id" ref="hr_timesheet.view_my_timesheet_line_pivot"/>
<field name="act_window_id" ref="act_hr_timesheet_line"/>
</record>
<record id="act_hr_timesheet_line_view_graph" model="ir.actions.act_window.view">
<field name="view_mode">graph</field>
<field name="sequence">8</field>
<field name="view_id" ref="hr_timesheet.view_hr_timesheet_line_graph_my"/>
<field name="act_window_id" ref="act_hr_timesheet_line"/>
</record>
<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>
@@ -58,7 +58,7 @@
</record>
<record id="action_hr_timesheet_attendance_report" model="ir.actions.act_window">
<field name="name">Timesheet / Attendance</field>
<field name="name">Timesheets / Attendance Analysis</field>
<field name="res_model">hr.timesheet.attendance.report</field>
<field name="view_mode">graph,pivot</field>
<field name="view_id" eval="False"/>
@@ -88,6 +88,6 @@
<menuitem id="menu_hr_timesheet_attendance_report"
parent="hr_timesheet.menu_timesheets_reports"
action="action_hr_timesheet_attendance_report"
name="Timesheet / Attendance"/>
name="Timesheets / Attendance Analysis"/>
</data>
</odoo>
+1 -1
View File
@@ -82,7 +82,7 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal):
if search_in in ('so', 'all'):
search_domain = expression.OR([search_domain, [('so_line.order_id.name', 'ilike', search)]])
if search_in in ('invoice', 'all'):
invoices = request.env['account.move'].sudo().search([('name', 'ilike', search)])
invoices = request.env['account.move'].sudo().search(['|', ('name', 'ilike', search), ('id', 'ilike', search)])
domain = request.env['account.analytic.line']._timesheet_get_sale_domain(invoices.mapped('invoice_line_ids.sale_line_ids'), invoices)
search_domain = expression.OR([search_domain, domain])
return search_domain
@@ -94,8 +94,10 @@
<li class="list-group-item flex-grow-1">
<div class="btn-toolbar flex-sm-nowrap justify-content-center">
<div class="btn-group mb-1">
<t t-set="search_value" t-value="invoice.name"/>
<t t-if="invoice.state == 'draft'" t-set="search_value" t-value="invoice.id"/>
<a t-if="invoice.move_type == 'out_invoice' and invoice.state in ('draft', 'posted') and invoice.timesheet_count > 0"
target="_blank" t-att-href="'/my/timesheets?search_in=invoice&amp;search=%s' % invoice.name">View Timesheets</a>
target="_blank" t-att-href="'/my/timesheets?search_in=invoice&amp;search=%s' % search_value">View Timesheets</a>
</div>
</div>
</li>