Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
e0e3deac
Commit
e0e3deac
authored
7 years ago
by
Géry Debongnie
Browse files
Options
Downloads
Patches
Plain Diff
[REF] sale_timesheet: adapt to new guidelines
parent
be3c89d7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addons/sale_timesheet/static/src/js/timesheet_plan.js
+89
-53
89 additions, 53 deletions
addons/sale_timesheet/static/src/js/timesheet_plan.js
with
89 additions
and
53 deletions
addons/sale_timesheet/static/src/js/timesheet_plan.js
+
89
−
53
View file @
e0e3deac
odoo
.
define
(
'
sale_timesheet.ProjectPlan
'
,
function
(
require
)
{
'
use strict
'
;
var
ajax
=
require
(
'
web.ajax
'
);
var
ControlPanelMixin
=
require
(
'
web.ControlPanelMixin
'
);
var
Context
=
require
(
'
web.Context
'
);
var
core
=
require
(
'
web.core
'
);
var
data
=
require
(
'
web.data
'
);
var
pyeval
=
require
(
'
web.pyeval
'
);
var
SearchView
=
require
(
'
web.SearchView
'
);
var
session
=
require
(
'
web.session
'
);
var
Widget
=
require
(
'
web.Widget
'
);
var
QWeb
=
core
.
qweb
;
var
_t
=
core
.
_t
;
var
P
lanActio
n
=
Widget
.
extend
(
ControlPanelMixin
,
{
var
P
rojectPla
n
=
Widget
.
extend
(
ControlPanelMixin
,
{
events
:
{
"
click a[type='action']
"
:
"
_onClickAction
"
,
"
click .o_timesheet_plan_redirect
"
:
'
_onRedirect
'
,
"
click .oe_stat_button
"
:
"
_onClickStatButton
"
,
"
click .o_timesheet_plan_sale_timesheet_people_time .progress-bar
"
:
'
_onClickEmployeeProgressbar
'
,
},
init
:
function
(
parent
,
action
,
options
)
{
/**
* @override
*/
init
:
function
(
parent
,
action
)
{
this
.
_super
.
apply
(
this
,
arguments
);
this
.
action
=
action
;
this
.
action_manager
=
parent
;
this
.
set
(
'
title
'
,
action
.
name
||
_t
(
'
Overview
'
));
},
/**
* @override
*/
willStart
:
function
()
{
var
self
=
this
;
var
view_id
=
this
.
action
&&
this
.
action
.
search_view_id
&&
this
.
action
.
search_view_id
[
0
];
...
...
@@ -37,7 +39,10 @@ var PlanAction = Widget.extend(ControlPanelMixin, {
});
return
$
.
when
(
this
.
_super
(),
def
);
},
start
:
function
(){
/**
* @override
*/
start
:
function
()
{
var
self
=
this
;
// find default search from context
...
...
@@ -77,48 +82,58 @@ var PlanAction = Widget.extend(ControlPanelMixin, {
// Public
//--------------------------------------------------------------------------
/**
* @override
*/
do_show
:
function
()
{
this
.
_super
.
apply
(
this
,
arguments
);
this
.
update
_cp
();
this
.
_
update
ControlPanel
();
this
.
action_manager
.
do_push_state
({
action
:
this
.
action
.
id
,
active_id
:
this
.
action
.
context
.
active_id
,
});
},
update_cp
:
function
()
{
this
.
update_control_panel
({
cp_content
:
{
$buttons
:
this
.
$buttons
,
$searchview
:
this
.
searchview
.
$el
,
$searchview_buttons
:
this
.
$searchview_buttons
,
},
searchview
:
this
.
searchview
,
});
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* Refresh the DOM html
*
@param {string|html} dom
*
* @private
* @param {string|html} dom
*/
_refreshPlan
:
function
(
dom
){
_refreshPlan
:
function
(
dom
)
{
this
.
$el
.
html
(
dom
);
},
/**
* Call controller to get the html content
*
* @private
* @param {string[]}
* @returns {Deferred}
*/
_fetchPlan
:
function
(
domain
){
_fetchPlan
:
function
(
domain
)
{
var
self
=
this
;
return
this
.
_rpc
({
route
:
"
/timesheet/plan
"
,
params
:
{
domain
:
domain
},
}).
then
(
function
(
result
){
self
.
_refreshPlan
(
result
[
'
html_content
'
]);
self
.
_refreshPlan
(
result
.
html_content
);
});
},
/**
* @private
*/
_updateControlPanel
:
function
()
{
this
.
update_control_panel
({
cp_content
:
{
$buttons
:
this
.
$buttons
,
$searchview
:
this
.
searchview
.
$el
,
$searchview_buttons
:
this
.
$searchview_buttons
,
},
searchview
:
this
.
searchview
,
});
},
...
...
@@ -129,35 +144,35 @@ var PlanAction = Widget.extend(ControlPanelMixin, {
/**
* Generate the action to execute based on the clicked target
*
* @param {MouseEvent} event
* @private
* @param {MouseEvent} event
*/
_onClickAction
:
function
(
ev
){
_onClickAction
:
function
(
ev
)
{
var
$target
=
this
.
$
(
ev
.
currentTarget
);
var
action
=
false
;
if
(
$target
.
attr
(
'
name
'
)){
// classical case : name="action_id" type="action"
action
=
$target
.
attr
(
'
name
'
)
}
else
{
// custom case : build custom action dict
action
=
$target
.
attr
(
'
name
'
)
;
}
else
{
// custom case : build custom action dict
action
=
{
'
name
'
:
_t
(
'
Timesheet
'
),
'
type
'
:
'
ir.actions.act_window
'
,
'
target
'
:
'
current
'
,
'
res_model
'
:
'
account.analytic.line
'
,
}
}
;
// find action views
var
views
=
[[
false
,
'
pivot
'
],
[
false
,
'
list
'
]];
if
(
$target
.
attr
(
'
views
'
)){
views
=
JSON
.
parse
(
$target
.
attr
(
'
views
'
).
replace
(
/
\'
/g
,
'
"
'
));
}
action
[
'
views
'
]
=
views
;
action
[
'
view_mode
'
]
=
_
.
map
(
views
,
function
(
view_array
){
return
view_array
[
1
];});
action
.
views
=
views
;
action
.
view_mode
=
_
.
map
(
views
,
function
(
view_array
){
return
view_array
[
1
];});
// custom domain
var
domain
=
[];
if
(
$target
.
attr
(
'
domain
'
)){
domain
=
JSON
.
parse
(
$target
.
attr
(
'
domain
'
).
replace
(
/
\'
/g
,
'
"
'
));
}
action
[
'
domain
'
]
=
domain
;
action
.
domain
=
domain
;
}
// additionnal context
...
...
@@ -176,57 +191,78 @@ var PlanAction = Widget.extend(ControlPanelMixin, {
additional_context
:
context
});
},
_onRedirect
:
function
(
event
)
{
event
.
preventDefault
();
var
$target
=
$
(
event
.
target
);
/**
* @private
* @param {MouseEvent} event
*/
_onClickEmployeeProgressbar
:
function
(
event
)
{
var
domain
=
$
(
event
.
currentTarget
).
data
(
'
domain
'
);
this
.
do_action
({
name
:
'
Timesheets
'
,
type
:
'
ir.actions.act_window
'
,
view_type
:
'
form
'
,
res_model
:
'
account.analytic.line
'
,
views
:
[[
false
,
'
list
'
],
[
false
,
'
form
'
]],
view_type
:
'
list
'
,
view_mode
:
'
form
'
,
res_model
:
$target
.
data
(
'
oe-model
'
),
views
:
[[
false
,
'
form
'
]],
res_id
:
$target
.
data
(
'
oe-id
'
),
domain
:
domain
,
});
},
_onClickStatButton
:
function
(
event
){
/**
* @private
* @param {MouseEvent} event
*/
_onClickStatButton
:
function
(
event
)
{
var
self
=
this
;
var
data
=
$
(
event
.
currentTarget
).
data
();
return
this
.
_rpc
({
route
:
"
/timesheet/plan/action
"
,
params
:
{
domain
:
data
[
'
domain
'
]
,
res_model
:
data
[
'
resModel
'
]
,
domain
:
data
.
domain
,
res_model
:
data
.
resModel
,
},
}).
then
(
function
(
action
){
self
.
do_action
(
action
);
});
},
_onClickEmployeeProgressbar
:
function
(
event
){
var
domain
=
$
(
event
.
currentTarget
).
data
(
'
domain
'
);
/**
* @private
* @param {MouseEvent} event
*/
_onRedirect
:
function
(
event
)
{
event
.
preventDefault
();
var
$target
=
$
(
event
.
target
);
this
.
do_action
({
name
:
'
Timesheets
'
,
type
:
'
ir.actions.act_window
'
,
res_model
:
'
account.analytic.line
'
,
views
:
[[
false
,
'
list
'
],
[
false
,
'
form
'
]],
view_type
:
'
list
'
,
view_type
:
'
form
'
,
view_mode
:
'
form
'
,
domain
:
domain
,
res_model
:
$target
.
data
(
'
oe-model
'
),
views
:
[[
false
,
'
form
'
]],
res_id
:
$target
.
data
(
'
oe-id
'
),
});
},
_onSearch
:
function
(
search_event
)
{
search_event
.
stopPropagation
();
/**
* This client action has its own search view and already listen on it. If
* we let the event pass through, it will be caught by the action manager
* which will do its work. This may crash the web client, if the action
* manager tries to notify the previous action.
*
* @private
* @param {OdooEvent} event
*/
_onSearch
:
function
(
event
)
{
event
.
stopPropagation
();
var
session
=
this
.
getSession
();
// group by are disabled, so we don't take care of them
var
result
=
pyeval
.
eval_domains_and_contexts
({
domains
:
search_
event
.
data
.
domains
,
contexts
:
[
session
.
user_context
].
concat
(
search_
event
.
data
.
contexts
)
domains
:
event
.
data
.
domains
,
contexts
:
[
session
.
user_context
].
concat
(
event
.
data
.
contexts
)
});
this
.
_fetchPlan
(
result
.
domain
);
},
});
core
.
action_registry
.
add
(
'
timesheet.plan
'
,
P
lanActio
n
);
core
.
action_registry
.
add
(
'
timesheet.plan
'
,
P
rojectPla
n
);
return
P
lanActio
n
;
return
P
rojectPla
n
;
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment