[FIX] sale_timesheet: non billable task from plan project

We want to retrieve easily the non billable task from
project plan. This commit makes the "Non billable" label
clickable, in the "Hours" sections, and trigger the actions
to display non billable tasks of projects matching the search
of the overview.

Task #1834454
This commit is contained in:
jem-odoo
2018-04-11 16:19:13 +02:00
parent 99ce19c7f3
commit c9098db40b
4 changed files with 25 additions and 2 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ class SaleTimesheetController(http.Controller):
values = self._plan_prepare_values(projects)
view = request.env.ref('sale_timesheet.timesheet_plan')
return {
'html_content': view.render(values)
'html_content': view.render(values),
'project_ids': projects.ids,
}
def _plan_prepare_values(self, projects):
@@ -15,6 +15,7 @@ var ProjectPlan = AbstractAction.extend(ControlPanelMixin, {
"click a[type='action']": "_onClickAction",
"click .o_timesheet_plan_redirect": '_onRedirect',
"click .oe_stat_button": "_onClickStatButton",
"click .o_timesheet_plan_non_billable_task": "_onClickNonBillableTask",
"click .o_timesheet_plan_sale_timesheet_people_time .progress-bar": '_onClickEmployeeProgressbar',
},
/**
@@ -25,6 +26,7 @@ var ProjectPlan = AbstractAction.extend(ControlPanelMixin, {
this.action = action;
this.action_manager = parent;
this.set('title', action.name || _t('Overview'));
this.project_ids = [];
},
/**
* @override
@@ -121,6 +123,7 @@ var ProjectPlan = AbstractAction.extend(ControlPanelMixin, {
params: {domain: domain},
}).then(function(result){
self._refreshPlan(result.html_content);
self.project_ids = result.project_ids;
});
},
/**
@@ -224,6 +227,22 @@ var ProjectPlan = AbstractAction.extend(ControlPanelMixin, {
self.do_action(action);
});
},
/**
* @private
* @param {MouseEvent} event
*/
_onClickNonBillableTask: function (event) {
var self = this;
this.do_action({
name: _t('Non Billable Tasks'),
type: 'ir.actions.act_window',
view_type: 'form',
view_mode: 'form',
res_model: 'project.task',
views: [[false, 'list'], [false, 'form']],
domain: [['project_id', 'in', this.project_ids || []], ['sale_line_id', '=', false]]
});
},
/**
* @private
* @param {MouseEvent} event
@@ -16,6 +16,9 @@
.table {
margin-top: 15px;
a {
cursor: pointer;
}
}
.table > thead > tr > th, .table > thead > tr > td,
.table > tbody > tr > th, .table > tbody > tr > td {
@@ -96,7 +96,7 @@
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['hours']['non_billable']" t-options="{'widget': 'float_time'}"/>
</td>
<td>Non billable</td>
<td><a class="o_timesheet_plan_non_billable_task">Non billable</a></td>
<td class="o_timesheet_plan_dashboard_cell">
<t t-esc="dashboard['rates']['non_billable']"/> %
</td>