Allow to deactivate button access
issue11284 review364911002
This commit is contained in:
1 parent
9c4d0aa334
commit
8f8cb9ba04
4 files changed
+24
-7
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Allow to deactivate button access
|
||||
* Always return tuple for MultiSelection
|
||||
* Use default selectors instead of select
|
||||
* Add batch option to push queue tasks
|
||||
|
||||
@@ -384,5 +384,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.message" id="msg_language_code_unique">
|
||||
<field name="text">The code on language must be unique.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_button_name_unique">
|
||||
<field name="text">The button name in model must be unique.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
+18
-6
@@ -10,12 +10,13 @@ from itertools import groupby
|
||||
from sql import Literal, Null
|
||||
from sql.aggregate import Max
|
||||
from sql.conditionals import Case
|
||||
from sql.operators import Equal
|
||||
|
||||
from trytond.cache import Cache
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model import (
|
||||
DeactivableMixin, EvalEnvironment, ModelSQL, ModelView, Unique, Workflow,
|
||||
fields)
|
||||
DeactivableMixin, EvalEnvironment, Exclude, ModelSQL, ModelView, Unique,
|
||||
Workflow, fields)
|
||||
from trytond.model.exceptions import AccessError, ValidationError
|
||||
from trytond.pool import Pool
|
||||
from trytond.protocols.jsonrpc import JSONDecoder, JSONEncoder
|
||||
@@ -834,7 +835,7 @@ class ModelFieldAccess(DeactivableMixin, ModelSQL, ModelView):
|
||||
ModelView._fields_view_get_cache.clear()
|
||||
|
||||
|
||||
class ModelButton(ModelSQL, ModelView):
|
||||
class ModelButton(DeactivableMixin, ModelSQL, ModelView):
|
||||
"Model Button"
|
||||
__name__ = 'ir.model.button'
|
||||
name = fields.Char('Name', required=True, readonly=True)
|
||||
@@ -869,13 +870,24 @@ class ModelButton(ModelSQL, ModelView):
|
||||
_view_attributes_cache = Cache(
|
||||
'ir.model.button.view_attributes', context=False)
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
super().__register__(module_name)
|
||||
|
||||
table_h = cls.__table_handler__(module_name)
|
||||
|
||||
# Migration from 6.2: replace unique by exclude
|
||||
table_h.drop_constraint('name_model_uniq')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(ModelButton, cls).__setup__()
|
||||
table = cls.__table__()
|
||||
t = cls.__table__()
|
||||
cls._sql_constraints += [
|
||||
('name_model_uniq', Unique(table, table.name, table.model),
|
||||
'The button name in model must be unique!'),
|
||||
('name_model_exclude',
|
||||
Exclude(t, (t.name, Equal), (t.model, Equal),
|
||||
where=(t.active == Literal(True))),
|
||||
'ir.msg_button_name_unique'),
|
||||
]
|
||||
cls._order.insert(0, ('model', 'ASC'))
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name"/>
|
||||
<label name="string"/>
|
||||
<field name="string"/>
|
||||
<newline/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<separator name="help" colspan="4"/>
|
||||
<field name="help" colspan="4"/>
|
||||
<separator name="confirm" colspan="4"/>
|
||||
|
||||
Reference in new issue
Block a user