[IMP] hr_timesheet, sale_timesheet: add a group by inv/so in portal view
Currently, user cannot group the timesheet by inv/so in portal view. In this commit, add a group the timesheet by inv/so in portal view and move the `view timesheets` button next th each sol to the top left pannel. closes odoo/odoo#65932 Taskid: 2451359 Related: odoo/upgrade#2214 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Mitali Patel
parent
0d0ba71f85
commit
dc9ef81ab2
@@ -54,7 +54,10 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal):
|
||||
|
||||
def _get_searchbar_groupby(self):
|
||||
searchbar_groupby = super()._get_searchbar_groupby()
|
||||
searchbar_groupby.update(sol={'input': 'sol', 'label': _('Sales Order Item')})
|
||||
searchbar_groupby.update(
|
||||
sol={'input': 'sol', 'label': _('Sales Order Item')},
|
||||
so={'input': 'so', 'label': _('Sales Order')},
|
||||
invoice={'input': 'invoice', 'label': _('Invoice')})
|
||||
return searchbar_groupby
|
||||
|
||||
def _get_search_domain(self, search_in, search):
|
||||
@@ -71,7 +74,10 @@ class SaleTimesheetCustomerPortal(TimesheetCustomerPortal):
|
||||
|
||||
def _get_groupby_mapping(self):
|
||||
groupby_mapping = super()._get_groupby_mapping()
|
||||
groupby_mapping.update(sol='so_line')
|
||||
groupby_mapping.update(
|
||||
sol='so_line',
|
||||
so='order_id',
|
||||
invoice='timesheet_invoice_id')
|
||||
return groupby_mapping
|
||||
|
||||
@http.route(['/my/timesheets', '/my/timesheets/page/<int:page>'], type='http', auth="user", website=True)
|
||||
|
||||
@@ -21,6 +21,8 @@ class AccountAnalyticLine(models.Model):
|
||||
('non_billable_project', 'No task found')], string="Billable Type", compute='_compute_timesheet_invoice_type', compute_sudo=True, store=True, readonly=True)
|
||||
timesheet_invoice_id = fields.Many2one('account.move', string="Invoice", readonly=True, copy=False, help="Invoice created from the timesheet")
|
||||
so_line = fields.Many2one(compute="_compute_so_line", store=True, readonly=False)
|
||||
# we needed to store it only in order to be able to groupby in the portal
|
||||
order_id = fields.Many2one(related='so_line.order_id', store=True, readonly=False)
|
||||
is_so_line_edited = fields.Boolean("Is Sales Order Item Manually Edited")
|
||||
|
||||
# TODO: [XBO] Since the task_id is not required in this model, then it should more efficient to depends to pricing_type of project (See in master)
|
||||
|
||||
@@ -7,9 +7,15 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="sale_order_portal_content_inherit" inherit_id="sale.sale_order_portal_content">
|
||||
<xpath expr="//td[@id='product_name']" position="inside">
|
||||
<a t-if="timesheets and len(timesheets.filtered(lambda t: t.so_line == line)) > 0" t-att-href="'/my/timesheets?search_in=so&search=%s' % line.order_id.name">View Timesheets</a>
|
||||
<template id="sale_order_portal_content_inherit" inherit_id="sale.sale_order_portal_template">
|
||||
<xpath expr="//li[.//a[@id='print_invoice_report']]" position="after">
|
||||
<li t-if="sale_order.timesheet_count > 0 and sale_order.state in ('sale', 'done')" class="list-group-item flex-grow-1">
|
||||
<div class="btn-toolbar flex-sm-nowrap justify-content-center">
|
||||
<div class="btn-group">
|
||||
<a t-att-href="'/my/timesheets?search_in=so&search=%s' % sale_order.name">View Timesheets</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
@@ -35,6 +41,40 @@
|
||||
</t>
|
||||
</th>
|
||||
</t>
|
||||
<t t-elif="groupby == 'so'">
|
||||
<t t-set="so" t-value="timesheets[0].order_id"/>
|
||||
<th colspan="6">
|
||||
<t t-if="so">
|
||||
<em class="font-weight-normal text-muted">Timesheets for sales order:</em>
|
||||
<span t-field="so.display_name"/>
|
||||
</t>
|
||||
</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 == 'invoice'">
|
||||
<t t-set="invoice" t-value="timesheets[0].timesheet_invoice_id"/>
|
||||
<th colspan="6">
|
||||
<t t-if="invoice">
|
||||
<em class="font-weight-normal text-muted">Timesheets for Invoice:</em>
|
||||
<span t-field="invoice.display_name"/>
|
||||
</t>
|
||||
</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>
|
||||
</xpath>
|
||||
<xpath expr="//thead/tr/th[@t-if='is_uom_day']" position="before">
|
||||
<th t-if="not groupby == 'sol'">Sale Order Item</th>
|
||||
|
||||
Reference in New Issue
Block a user