Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
vauxoo
isolated_addons
Commits
a8396514
Commit
a8396514
authored
Jun 05, 2017
by
George Daramouskas
Committed by
Jairo Llopis
Jun 05, 2017
Browse files
[MIG] Migration from 9.0 to 10.0 web_access_rule_buttons (#628)
* [MIG] Migration from 9.0 to 10.0 * Refactoring javascript code
parent
10f1b9be
Changes
5
Hide whitespace changes
Inline
Side-by-side
web_access_rule_buttons/README.rst
View file @
a8396514
...
...
@@ -19,7 +19,7 @@ Now, the user won't be able to click on the Edit button.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/
9
.0
:target: https://runbot.odoo-community.org/runbot/162/
10
.0
Known issues / Roadmap
======================
...
...
@@ -37,7 +37,7 @@ help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
web/issues/new?body=module:%20
web_access_rule_buttons%0Aversion:%20
9
.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
10
.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
...
...
web_access_rule_buttons/__manifest__.py
View file @
a8396514
...
...
@@ -4,7 +4,7 @@
{
'name'
:
'Web Access Rules Buttons'
,
'summary'
:
'Disable Edit button if access rules prevent this action'
,
'version'
:
'
9
.0.1.0.0'
,
'version'
:
'
10
.0.1.0.0'
,
'author'
:
'Camptocamp,Odoo Community Association (OCA)'
,
'license'
:
'AGPL-3'
,
'category'
:
'Web'
,
...
...
@@ -13,5 +13,5 @@
'website'
:
'http://www.camptocamp.com'
,
'data'
:
[
'views/web_access_rule_buttons.xml'
,
],
'installable'
:
Fals
e
,
'installable'
:
Tru
e
,
}
web_access_rule_buttons/models.py
View file @
a8396514
...
...
@@ -2,7 +2,7 @@
# © 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from
o
penerp
import
models
,
api
,
exceptions
from
o
doo
import
models
,
api
,
exceptions
@
api
.
multi
...
...
web_access_rule_buttons/static/src/js/web_access_rule_buttons.js
View file @
a8396514
...
...
@@ -2,43 +2,30 @@
* © 2016 Camptocamp SA
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
*/
odoo
.
define
(
'
web_access_rule_buttons.main
'
,
function
(
require
)
{
"
use strict
"
;
var
core
=
require
(
'
web.core
'
);
var
FormView
=
require
(
'
web.FormView
'
);
var
ListView
=
require
(
'
web.ListView
'
);
FormView
.
include
({
load_record
:
function
()
{
var
self
=
this
;
return
this
.
_super
.
apply
(
this
,
arguments
)
.
then
(
function
()
{
self
.
show_hide_buttons
()
});
},
show_hide_buttons
:
function
()
{
var
self
=
this
;
this
.
dataset
.
call
(
'
check_access_rule_all
'
,
[[
this
.
datarecord
.
id
],
[
'
write
'
]])
.
then
(
function
(
accesses
)
{
self
.
show_hide_edit_button
(
accesses
.
write
);
});
},
show_hide_edit_button
:
function
(
access
)
{
if
(
this
.
$buttons
)
{
var
button
=
this
.
$buttons
.
find
(
'
.oe_form_button_edit
'
);
if
(
button
)
{
button
.
prop
(
'
disabled
'
,
!
access
);
}
}
}
});
odoo
.
define
(
"
web_access_rule_buttons.main
"
,
function
(
require
)
{
"
use strict
"
;
var
FormView
=
require
(
"
web.FormView
"
);
FormView
.
include
({
load_record
:
function
()
{
return
this
.
_super
.
apply
(
this
,
arguments
).
then
(
$
.
proxy
(
this
.
show_hide_buttons
,
this
));
},
show_hide_buttons
:
function
()
{
var
self
=
this
;
this
.
dataset
.
call
(
"
check_access_rule_all
"
,
[
[
this
.
datarecord
.
id
],
[
"
write
"
]
]).
then
(
function
(
accesses
)
{
self
.
show_hide_edit_button
(
accesses
.
write
);
});
},
show_hide_edit_button
:
function
(
access
)
{
if
(
this
.
$buttons
)
{
var
button
=
this
.
$buttons
.
find
(
"
.o_form_button_edit
"
);
if
(
button
)
{
button
.
prop
(
"
disabled
"
,
!
access
);
}
}
}
});
});
web_access_rule_buttons/views/web_access_rule_buttons.xml
View file @
a8396514
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template
id=
"assets_backend"
name=
"web_access_rule_buttons assets"
inherit_id=
"web.assets_backend"
>
<xpath
expr=
"."
position=
"inside"
>
<script
type=
"text/javascript"
src=
"/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js"
></script>
</xpath>
</template>
</data>
</openerp>
<odoo>
<template
id=
"assets_backend"
name=
"web_access_rule_buttons assets"
inherit_id=
"web.assets_backend"
>
<xpath
expr=
"."
position=
"inside"
>
<script
type=
"text/javascript"
src=
"/web_access_rule_buttons/static/src/js/web_access_rule_buttons.js"
></script>
</xpath>
</template>
</odoo>
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment