Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Board Alerts
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
XCG
Odoo modules
Board Alerts
Commits
03d77e2f
Commit
03d77e2f
authored
6 years ago
by
Houzefa Abbasbhay
Browse files
Options
Downloads
Patches
Plain Diff
Update "Add to my alert board" for Odoo 11
parent
968f3094
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/add_to_alert_dashboard.py
+8
-5
8 additions, 5 deletions
controllers/add_to_alert_dashboard.py
static/src/js/alert_board.js
+45
-36
45 additions, 36 deletions
static/src/js/alert_board.js
static/src/less/alert_board.less
+1
-1
1 addition, 1 deletion
static/src/less/alert_board.less
with
54 additions
and
42 deletions
controllers/add_to_alert_dashboard.py
+
8
−
5
View file @
03d77e2f
...
@@ -8,6 +8,8 @@
...
@@ -8,6 +8,8 @@
dashboard added by this module.
dashboard added by this module.
Similar to the one for the default dashboard in the
"
board
"
module.
Similar to the one for the default dashboard in the
"
board
"
module.
Ref: odoo/addons/board/controllers/main.py
"""
"""
@route
(
route
=
'
/board/add_to_alert_dashboard
'
,
type
=
'
json
'
,
auth
=
'
user
'
)
@route
(
route
=
'
/board/add_to_alert_dashboard
'
,
type
=
'
json
'
,
auth
=
'
user
'
)
...
@@ -22,6 +24,7 @@
...
@@ -22,6 +24,7 @@
action
and
action
[
'
res_model
'
]
==
'
board.board
'
and
action
and
action
[
'
res_model
'
]
==
'
board.board
'
and
action
[
'
views
'
][
0
][
1
]
==
'
form
'
and
action_id
action
[
'
views
'
][
0
][
1
]
==
'
form
'
and
action_id
):
):
# Maybe should check the content instead of model board.board ?
view_id
=
action
[
'
views
'
][
0
][
0
]
view_id
=
action
[
'
views
'
][
0
][
0
]
board
=
request
.
env
[
'
board.board
'
].
fields_view_get
(
view_id
,
'
form
'
)
board
=
request
.
env
[
'
board.board
'
].
fields_view_get
(
view_id
,
'
form
'
)
if
board
and
'
arch
'
in
board
:
if
board
and
'
arch
'
in
board
:
...
@@ -29,8 +32,6 @@
...
@@ -29,8 +32,6 @@
column
=
xml
.
find
(
'
./board/column
'
)
column
=
xml
.
find
(
'
./board/column
'
)
if
column
is
not
None
:
if
column
is
not
None
:
new_action
=
ElementTree
.
Element
(
'
action
'
,
{
new_action
=
ElementTree
.
Element
(
'
action
'
,
{
'
context
'
:
str
(
context_to_save
),
'
domain
'
:
str
(
domain
),
'
name
'
:
str
(
action_id
),
'
name
'
:
str
(
action_id
),
'
string
'
:
name
,
'
string
'
:
name
,
'
view_mode
'
:
view_mode
,
'
view_mode
'
:
view_mode
,
...
@@ -34,5 +35,7 @@
...
@@ -34,5 +35,7 @@
'
name
'
:
str
(
action_id
),
'
name
'
:
str
(
action_id
),
'
string
'
:
name
,
'
string
'
:
name
,
'
view_mode
'
:
view_mode
,
'
view_mode
'
:
view_mode
,
'
context
'
:
str
(
context_to_save
),
'
domain
'
:
str
(
domain
)
})
})
column
.
insert
(
0
,
new_action
)
column
.
insert
(
0
,
new_action
)
...
@@ -37,4 +40,4 @@
...
@@ -37,4 +40,4 @@
})
})
column
.
insert
(
0
,
new_action
)
column
.
insert
(
0
,
new_action
)
arch
=
ElementTree
.
tostring
(
xml
,
'
utf-8
'
)
arch
=
ElementTree
.
tostring
(
xml
,
encoding
=
'
unicode
'
)
request
.
env
[
'
ir.ui.view.custom
'
].
create
({
request
.
env
[
'
ir.ui.view.custom
'
].
create
({
...
@@ -40,3 +43,3 @@
...
@@ -40,3 +43,3 @@
request
.
env
[
'
ir.ui.view.custom
'
].
create
({
request
.
env
[
'
ir.ui.view.custom
'
].
create
({
'
arch
'
:
arch
,
'
user_id
'
:
request
.
session
.
uid
,
'
ref_id
'
:
view_id
,
'
ref_id
'
:
view_id
,
...
@@ -42,5 +45,5 @@
...
@@ -42,5 +45,5 @@
'
ref_id
'
:
view_id
,
'
ref_id
'
:
view_id
,
'
user_id
'
:
request
.
session
.
uid
,
'
arch
'
:
arch
})
})
return
True
return
True
...
...
This diff is collapsed.
Click to expand it.
static/src/js/alert_board.js
+
45
−
36
View file @
03d77e2f
// TODO migration: Implementation in odoo 11 js changed. FIX IT
/* Alert board. */
/* Alert board. */
/* Taken from the default "My board" dashboard.
/* Taken from the default "My board" dashboard.
...
@@ -2,7 +1,7 @@
...
@@ -2,7 +1,7 @@
/* Alert board. */
/* Alert board. */
/* Taken from the default "My board" dashboard.
/* Taken from the default "My board" dashboard.
* Ref: odoo/addons/board/static/
js/dashboard
.js.
* Ref: odoo/addons/board/static/
src/js/favorite_menu
.js.
*
*
* Adapted to add an "Add to my alert board" menu command.
* Adapted to add an "Add to my alert board" menu command.
*/
*/
...
@@ -11,4 +10,5 @@
...
@@ -11,4 +10,5 @@
'
use strict
'
;
'
use strict
'
;
var
ActionManager
=
require
(
'
web.ActionManager
'
);
var
ActionManager
=
require
(
'
web.ActionManager
'
);
var
Context
=
require
(
'
web.Context
'
);
var
core
=
require
(
'
web.core
'
);
var
core
=
require
(
'
web.core
'
);
...
@@ -14,3 +14,3 @@
...
@@ -14,3 +14,3 @@
var
core
=
require
(
'
web.core
'
);
var
core
=
require
(
'
web.core
'
);
var
data
=
require
(
'
web.
data
'
);
var
Domain
=
require
(
'
web.
Domain
'
);
var
FavoriteMenu
=
require
(
'
web.FavoriteMenu
'
);
var
FavoriteMenu
=
require
(
'
web.FavoriteMenu
'
);
...
@@ -16,4 +16,3 @@
...
@@ -16,4 +16,3 @@
var
FavoriteMenu
=
require
(
'
web.FavoriteMenu
'
);
var
FavoriteMenu
=
require
(
'
web.FavoriteMenu
'
);
var
Model
=
require
(
'
web.DataModel
'
);
var
pyeval
=
require
(
'
web.pyeval
'
);
var
pyeval
=
require
(
'
web.pyeval
'
);
var
ViewManager
=
require
(
'
web.ViewManager
'
);
var
ViewManager
=
require
(
'
web.ViewManager
'
);
...
@@ -18,8 +17,7 @@
...
@@ -18,8 +17,7 @@
var
pyeval
=
require
(
'
web.pyeval
'
);
var
pyeval
=
require
(
'
web.pyeval
'
);
var
ViewManager
=
require
(
'
web.ViewManager
'
);
var
ViewManager
=
require
(
'
web.ViewManager
'
);
var
data_manager
=
require
(
'
web.data_manager
'
);
var
_t
=
core
.
_t
;
var
_t
=
core
.
_t
;
var
QWeb
=
core
.
qweb
;
var
QWeb
=
core
.
qweb
;
FavoriteMenu
.
include
({
FavoriteMenu
.
include
({
...
@@ -21,8 +19,10 @@
...
@@ -21,8 +19,10 @@
var
_t
=
core
.
_t
;
var
_t
=
core
.
_t
;
var
QWeb
=
core
.
qweb
;
var
QWeb
=
core
.
qweb
;
FavoriteMenu
.
include
({
FavoriteMenu
.
include
({
// Same as the base "start" function.
start
:
function
()
{
start
:
function
()
{
var
self
=
this
;
var
self
=
this
;
if
(
this
.
action_id
===
undefined
)
{
if
(
this
.
action_id
===
undefined
)
{
...
@@ -43,5 +43,5 @@
...
@@ -43,5 +43,5 @@
this
.
$add_alert_dashboard_input
.
val
(
title
);
this
.
$add_alert_dashboard_input
.
val
(
title
);
this
.
$add_alert_dashboard_link
.
click
(
function
(
e
)
{
this
.
$add_alert_dashboard_link
.
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
self
.
toggle
_a
lert
_d
ashboard
_m
enu
();
self
.
_
toggle
A
lert
D
ashboard
M
enu
();
});
});
...
@@ -47,5 +47,5 @@
...
@@ -47,5 +47,5 @@
});
});
this
.
$add_alert_dashboard_btn
.
click
(
this
.
proxy
(
'
add
_a
lert
_d
ashboard
'
));
this
.
$add_alert_dashboard_btn
.
click
(
this
.
proxy
(
'
_
add
A
lert
D
ashboard
'
));
}
}
return
this
.
_super
();
return
this
.
_super
();
},
},
...
@@ -49,21 +49,7 @@
...
@@ -49,21 +49,7 @@
}
}
return
this
.
_super
();
return
this
.
_super
();
},
},
toggle_alert_dashboard_menu
:
function
(
is_open
)
{
this
.
$add_alert_dashboard_link
.
toggleClass
(
// Same as the base "_addDashboard" function.
'
o_closed_menu
'
,
_addAlertDashboard
:
function
()
{
!
(
_
.
isUndefined
(
is_open
))
?
!
is_open
:
undefined
).
toggleClass
(
'
o_open_menu
'
,
is_open
);
this
.
$add_to_alert_dashboard
.
toggle
(
is_open
);
if
(
this
.
$add_alert_dashboard_link
.
hasClass
(
'
o_open_menu
'
))
{
this
.
$add_alert_dashboard_input
.
focus
();
}
},
close_menus
:
function
()
{
if
(
this
.
add_to_alert_dashboard_available
)
{
this
.
toggle_alert_dashboard_menu
(
false
);
}
this
.
_super
();
},
add_alert_dashboard
:
function
()
{
var
self
=
this
;
var
self
=
this
;
...
@@ -69,2 +55,5 @@
...
@@ -69,2 +55,5 @@
var
self
=
this
;
var
self
=
this
;
var
search_data
=
this
.
searchview
.
build_search_data
();
var
context
=
new
Context
(
this
.
searchview
.
dataset
.
get_context
()
||
[]);
var
domain
=
this
.
searchview
.
dataset
.
get_domain
()
||
[];
...
@@ -70,5 +59,2 @@
...
@@ -70,5 +59,2 @@
var
search_data
=
this
.
searchview
.
build_search_data
(),
context
=
new
data
.
CompoundContext
(
this
.
searchview
.
dataset
.
get_context
()
||
[]),
domain
=
new
data
.
CompoundDomain
(
this
.
searchview
.
dataset
.
get_domain
()
||
[]);
_
.
each
(
search_data
.
contexts
,
context
.
add
,
context
);
_
.
each
(
search_data
.
contexts
,
context
.
add
,
context
);
...
@@ -74,6 +60,8 @@
...
@@ -74,6 +60,8 @@
_
.
each
(
search_data
.
contexts
,
context
.
add
,
context
);
_
.
each
(
search_data
.
contexts
,
context
.
add
,
context
);
_
.
each
(
search_data
.
domains
,
domain
.
add
,
domain
);
_
.
each
(
search_data
.
domains
,
function
(
d
)
{
domain
.
push
.
apply
(
domain
,
Domain
.
prototype
.
stringToArray
(
d
));
});
context
.
add
({
context
.
add
({
group_by
:
pyeval
.
eval
(
'
groupbys
'
,
search_data
.
groupbys
||
[])
group_by
:
pyeval
.
eval
(
'
groupbys
'
,
search_data
.
groupbys
||
[])
});
});
...
@@ -76,11 +64,11 @@
...
@@ -76,11 +64,11 @@
context
.
add
({
context
.
add
({
group_by
:
pyeval
.
eval
(
'
groupbys
'
,
search_data
.
groupbys
||
[])
group_by
:
pyeval
.
eval
(
'
groupbys
'
,
search_data
.
groupbys
||
[])
});
});
context
.
add
(
this
.
view_manager
.
active_view
.
controller
.
get
_c
ontext
());
context
.
add
(
this
.
view_manager
.
active_view
.
controller
.
get
C
ontext
());
var
c
=
pyeval
.
eval
(
'
context
'
,
context
);
var
c
=
pyeval
.
eval
(
'
context
'
,
context
);
for
(
var
k
in
c
)
{
for
(
var
k
in
c
)
{
if
(
c
.
hasOwnProperty
(
k
)
&&
/^search_default_/
.
test
(
k
))
{
if
(
c
.
hasOwnProperty
(
k
)
&&
/^search_default_/
.
test
(
k
))
{
delete
c
[
k
];
delete
c
[
k
];
}
}
}
}
...
@@ -81,8 +69,8 @@
...
@@ -81,8 +69,8 @@
var
c
=
pyeval
.
eval
(
'
context
'
,
context
);
var
c
=
pyeval
.
eval
(
'
context
'
,
context
);
for
(
var
k
in
c
)
{
for
(
var
k
in
c
)
{
if
(
c
.
hasOwnProperty
(
k
)
&&
/^search_default_/
.
test
(
k
))
{
if
(
c
.
hasOwnProperty
(
k
)
&&
/^search_default_/
.
test
(
k
))
{
delete
c
[
k
];
delete
c
[
k
];
}
}
}
}
this
.
toggle
_a
lert
_d
ashboard
_m
enu
(
false
);
this
.
_
toggle
A
lert
D
ashboard
M
enu
(
false
);
c
.
dashboard_merge_domains_contexts
=
false
;
c
.
dashboard_merge_domains_contexts
=
false
;
...
@@ -88,5 +76,4 @@
...
@@ -88,5 +76,4 @@
c
.
dashboard_merge_domains_contexts
=
false
;
c
.
dashboard_merge_domains_contexts
=
false
;
var
d
=
pyeval
.
eval
(
'
domain
'
,
domain
),
board
=
new
Model
(
'
board.board
'
),
var
name
=
self
.
$add_alert_dashboard_input
.
val
();
name
=
self
.
$add_alert_dashboard_input
.
val
();
...
@@ -92,4 +79,6 @@
...
@@ -92,4 +79,6 @@
return
self
.
rpc
(
'
/board/add_to_alert_dashboard
'
,
{
return
self
.
_rpc
({
route
:
'
/board/add_to_alert_dashboard
'
,
params
:
{
action_id
:
self
.
action_id
||
false
,
action_id
:
self
.
action_id
||
false
,
context_to_save
:
c
,
context_to_save
:
c
,
...
@@ -94,5 +83,5 @@
...
@@ -94,5 +83,5 @@
action_id
:
self
.
action_id
||
false
,
action_id
:
self
.
action_id
||
false
,
context_to_save
:
c
,
context_to_save
:
c
,
domain
:
d
,
domain
:
d
omain
,
view_mode
:
self
.
view_manager
.
active_view
.
type
,
view_mode
:
self
.
view_manager
.
active_view
.
type
,
name
:
name
,
name
:
name
,
...
@@ -97,5 +86,6 @@
...
@@ -97,5 +86,6 @@
view_mode
:
self
.
view_manager
.
active_view
.
type
,
view_mode
:
self
.
view_manager
.
active_view
.
type
,
name
:
name
,
name
:
name
,
},
}).
then
(
function
(
r
)
{
}).
then
(
function
(
r
)
{
if
(
r
)
{
if
(
r
)
{
self
.
do_notify
(
_
.
str
.
sprintf
(
_t
(
"
'%s' added to alert dashboard
"
),
name
),
''
);
self
.
do_notify
(
_
.
str
.
sprintf
(
_t
(
"
'%s' added to alert dashboard
"
),
name
),
''
);
...
@@ -99,9 +89,8 @@
...
@@ -99,9 +89,8 @@
}).
then
(
function
(
r
)
{
}).
then
(
function
(
r
)
{
if
(
r
)
{
if
(
r
)
{
self
.
do_notify
(
_
.
str
.
sprintf
(
_t
(
"
'%s' added to alert dashboard
"
),
name
),
''
);
self
.
do_notify
(
_
.
str
.
sprintf
(
_t
(
"
'%s' added to alert dashboard
"
),
name
),
''
);
data_manager
.
invalidate
();
}
else
{
}
else
{
self
.
do_warn
(
_t
(
"
Could not add filter to alert dashboard
"
));
self
.
do_warn
(
_t
(
"
Could not add filter to alert dashboard
"
));
}
}
});
});
},
},
...
@@ -103,8 +92,28 @@
...
@@ -103,8 +92,28 @@
}
else
{
}
else
{
self
.
do_warn
(
_t
(
"
Could not add filter to alert dashboard
"
));
self
.
do_warn
(
_t
(
"
Could not add filter to alert dashboard
"
));
}
}
});
});
},
},
// Same as the base "_closeMenus" function.
_closeMenus
:
function
()
{
if
(
this
.
add_to_alert_dashboard_available
)
{
this
.
_toggleAlertDashboardMenu
(
false
);
}
this
.
_super
();
},
// Same as the base "_toggleDashboardMenu" function.
_toggleAlertDashboardMenu
:
function
(
isOpen
)
{
this
.
$add_alert_dashboard_link
// nowrap
.
toggleClass
(
'
o_closed_menu
'
,
!
(
_
.
isUndefined
(
isOpen
))
?
!
isOpen
:
undefined
)
// nowrap
.
toggleClass
(
'
o_open_menu
'
,
isOpen
);
this
.
$add_to_alert_dashboard
.
toggle
(
isOpen
);
if
(
this
.
$add_alert_dashboard_link
.
hasClass
(
'
o_open_menu
'
))
{
this
.
$add_alert_dashboard_input
.
focus
();
}
},
});
});
});
});
This diff is collapsed.
Click to expand it.
static/src/less/alert_board.less
+
1
−
1
View file @
03d77e2f
// Taken from default "My board" dashboard styles.
// Taken from default "My board" dashboard styles.
// Ref: odoo/addons/board/static/less/
alert_
board.less.
// Ref: odoo/addons/board/static/
src/
less/
dash
board.less.
// Adapted to add an "Add to my alert board" menu command.
// Adapted to add an "Add to my alert board" menu command.
...
...
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