[IMP] sale_timesheet: add project stat button on overview
The config of a project will become more important and usefull for project manager, so adding a shortcut from the overview to setup correclty its project makes sense. This commit adds this button on the overview. Task #34703
This commit is contained in:
@@ -362,6 +362,13 @@ class SaleTimesheetController(http.Controller):
|
||||
|
||||
def _plan_get_stat_button(self, projects):
|
||||
stat_buttons = []
|
||||
if len(projects) == 1:
|
||||
stat_buttons.append({
|
||||
'name': _('Project'),
|
||||
'res_model': 'project.project',
|
||||
'res_id': projects.id,
|
||||
'icon': 'fa fa-puzzle-piece',
|
||||
})
|
||||
stat_buttons.append({
|
||||
'name': _('Timesheets'),
|
||||
'res_model': 'account.analytic.line',
|
||||
@@ -397,7 +404,7 @@ class SaleTimesheetController(http.Controller):
|
||||
return stat_buttons
|
||||
|
||||
@http.route('/timesheet/plan/action', type='json', auth="user")
|
||||
def plan_stat_button(self, domain, res_model='account.analytic.line'):
|
||||
def plan_stat_button(self, domain=[], res_model='account.analytic.line', res_id=False):
|
||||
action = {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_id': False,
|
||||
@@ -405,7 +412,18 @@ class SaleTimesheetController(http.Controller):
|
||||
'view_type': 'list',
|
||||
'domain': domain,
|
||||
}
|
||||
if res_model == 'account.analytic.line':
|
||||
if res_model == 'project.project':
|
||||
view_form_id = request.env.ref('project.edit_project').id
|
||||
action = {
|
||||
'name': _('Project'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': res_model,
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'views': [[view_form_id, 'form']],
|
||||
'res_id': res_id,
|
||||
}
|
||||
elif res_model == 'account.analytic.line':
|
||||
ts_view_tree_id = request.env.ref('hr_timesheet.hr_timesheet_line_tree').id
|
||||
ts_view_form_id = request.env.ref('hr_timesheet.hr_timesheet_line_form').id
|
||||
action = {
|
||||
|
||||
@@ -232,7 +232,7 @@ var ProjectPlan = AbstractAction.extend(ControlPanelMixin, {
|
||||
views: [[false, 'list'], [false, 'form']],
|
||||
view_type: 'list',
|
||||
view_mode: 'form',
|
||||
domain: domain,
|
||||
domain: domain || [],
|
||||
});
|
||||
},
|
||||
/**
|
||||
@@ -242,12 +242,16 @@ var ProjectPlan = AbstractAction.extend(ControlPanelMixin, {
|
||||
_onClickStatButton: function (event) {
|
||||
var self = this;
|
||||
var data = $(event.currentTarget).data();
|
||||
var parameters = {
|
||||
domain: data.domain || [],
|
||||
res_model: data.resModel,
|
||||
}
|
||||
if (data.resId) {
|
||||
parameters['res_id'] = data.resId;
|
||||
}
|
||||
return this._rpc({
|
||||
route:"/timesheet/plan/action",
|
||||
params: {
|
||||
domain: data.domain,
|
||||
res_model: data.resModel,
|
||||
},
|
||||
params: parameters,
|
||||
}).then(function(action){
|
||||
self.do_action(action);
|
||||
});
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
|
||||
<div class="o_timesheet_plan_stat_buttons oe_button_box">
|
||||
<t t-foreach="stat_buttons" t-as="stat_button">
|
||||
<button class="btn oe_stat_button" t-att-data-domain="stat_button['domain']" t-att-data-res-model="stat_button['res_model']">
|
||||
<button class="btn oe_stat_button" t-att-data-domain="stat_button.get('domain')" t-att-data-res-model="stat_button['res_model']" t-att-data-res-id="stat_button.get('res_id')">
|
||||
<div t-attf-class="fa fa-fw o_button_icon #{stat_button['icon']}" role="img" aria-label="Statistics" title="Statistics"></div>
|
||||
<div name="task_count" class="o_field_widget o_stat_info o_readonly_modifier" t-att-title="stat_button['name']">
|
||||
<div class="o_field_widget o_stat_info o_readonly_modifier" t-att-title="stat_button['name']">
|
||||
<span class="o_stat_value" t-if="stat_button.get('count')">
|
||||
<t t-esc="stat_button['count']"/>
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user