diff --git a/CHANGELOG b/CHANGELOG
index 1c5638ce82..8f12ad3ff8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Merge all kind of buttons
* Use XML id for board action instead of id
* Add states attribute to notebook
* Allow to use tuple for Reference
diff --git a/doc/ref/models/models.rst b/doc/ref/models/models.rst
index 2a24c3a72d..72def97bd6 100644
--- a/doc/ref/models/models.rst
+++ b/doc/ref/models/models.rst
@@ -117,6 +117,11 @@ Static methods:
Decorate button method to check group access.
+.. staticmethod:: ModelView.button_action(action)
+
+ Same as :stat:`ModelView.button` but return the action id of the XML `id`
+ action.
+
Instance methods:
.. method:: ModelView.fields_view_get([view_id[, view_type[, toolbar]]])
diff --git a/trytond/ir/module/module.xml b/trytond/ir/module/module.xml
index 2ec2b309c7..79ad2644df 100644
--- a/trytond/ir/module/module.xml
+++ b/trytond/ir/module/module.xml
@@ -18,18 +18,12 @@ this repository contains the full copyright notices and license terms. -->
-
-
-
-
-
-
+
+
+
+
+
+
]]>
@@ -45,14 +39,10 @@ this repository contains the full copyright notices and license terms. -->
-
-
-
-
+
+
+
+
]]>
diff --git a/trytond/ir/ui/form.rnc b/trytond/ir/ui/form.rnc
index d2860fd54c..ab52e0d308 100644
--- a/trytond/ir/ui/form.rnc
+++ b/trytond/ir/ui/form.rnc
@@ -137,12 +137,8 @@ attlist.button &= attribute help { text }?
attlist.button &=
[ a:defaultValue = "Unknown" ] attribute string { text }?
attlist.button &= attribute icon { text }?
-attlist.button &=
- [ a:defaultValue = "object" ]
- attribute type { "object" | "action" }?
attlist.button &= attribute confirm { text }?
attlist.button &= attribute name { text }
-attlist.button &= attribute states { text }?
notebook = element notebook { attlist.notebook, page* }
attlist.notebook &= [ a:defaultValue = "4" ] attribute colspan { text }?
attlist.notebook &= attribute states { text }?
diff --git a/trytond/ir/ui/form.rng b/trytond/ir/ui/form.rng
index a16208e7f9..107ac81407 100644
--- a/trytond/ir/ui/form.rng
+++ b/trytond/ir/ui/form.rng
@@ -530,16 +530,6 @@
-
-
-
-
- object
- action
-
-
-
-
@@ -548,11 +538,6 @@
-
-
-
-
-
diff --git a/trytond/ir/ui/tree.rnc b/trytond/ir/ui/tree.rnc
index 280fea1820..c52067b974 100644
--- a/trytond/ir/ui/tree.rnc
+++ b/trytond/ir/ui/tree.rnc
@@ -54,12 +54,8 @@ button = element button { attlist.button, empty }
attlist.button &= attribute help { text }?
attlist.button &=
[ a:defaultValue = "Unknown" ] attribute string { text }?
-attlist.button &=
- [ a:defaultValue = "object" ]
- attribute type { "object" | "action" }?
attlist.button &= attribute confirm { text }?
attlist.button &= attribute name { text }
-attlist.button &= attribute states { text }?
data = element data { attlist.data, xpath+ }
attlist.data &= empty
xpath = element xpath { attlist.xpath,
diff --git a/trytond/ir/ui/tree.rng b/trytond/ir/ui/tree.rng
index edd1727ed8..5ecd857845 100644
--- a/trytond/ir/ui/tree.rng
+++ b/trytond/ir/ui/tree.rng
@@ -163,16 +163,6 @@
-
-
-
-
- object
- action
-
-
-
-
@@ -181,11 +171,6 @@
-
-
-
-
-
diff --git a/trytond/ir/ui/view.py b/trytond/ir/ui/view.py
index e96bde4b67..7d84395ac0 100644
--- a/trytond/ir/ui/view.py
+++ b/trytond/ir/ui/view.py
@@ -50,6 +50,9 @@ class View(ModelSQL, ModelView):
'invalid_xml': 'Invalid XML for View!',
})
self._order.insert(0, ('priority', 'ASC'))
+ self._buttons.update({
+ 'show': {},
+ })
def init(self, module_name):
super(View, self).init(module_name)
@@ -70,6 +73,10 @@ class View(ModelSQL, ModelView):
def default_module(self):
return Transaction().context.get('module') or ''
+ @ModelView.button_action('ir.act_view_show')
+ def show(self, ids):
+ pass
+
def check_xml(self, ids):
"Check XML"
pool = Pool()
diff --git a/trytond/ir/ui/view.xml b/trytond/ir/ui/view.xml
index 76814ed407..7097c74914 100644
--- a/trytond/ir/ui/view.xml
+++ b/trytond/ir/ui/view.xml
@@ -29,11 +29,7 @@ this repository contains the full copyright notices and license terms. -->
-
+
]]>
diff --git a/trytond/model/modelview.py b/trytond/model/modelview.py
index 6bacf83435..babf53184c 100644
--- a/trytond/model/modelview.py
+++ b/trytond/model/modelview.py
@@ -450,19 +450,17 @@ class ModelView(Model):
CONTEXT)))
if element.tag == 'button':
- if element.get('type', 'object') == 'object':
- assert not element.get('states')
- button_name = element.attrib['name']
- if button_name in self._buttons:
- states = self._buttons[button_name]
- else:
- states = {}
- groups = set(user_obj.get_groups())
- button_groups = button_obj.get_groups(self._name, button_name)
- if button_groups and not groups & button_groups:
- states = states.copy()
- states['readonly'] = True
- element.set('states', encoder.encode(states))
+ button_name = element.attrib['name']
+ if button_name in self._buttons:
+ states = self._buttons[button_name]
+ else:
+ states = {}
+ groups = set(user_obj.get_groups())
+ button_groups = button_obj.get_groups(self._name, button_name)
+ if button_groups and not groups & button_groups:
+ states = states.copy()
+ states['readonly'] = True
+ element.set('states', encoder.encode(states))
# translate view
if Transaction().language != 'en_US':
@@ -504,3 +502,23 @@ class ModelView(Model):
% (func.__name__, self._name))
return func(self, *args, **kwargs)
return wrapper
+
+ @staticmethod
+ def button_action(action):
+ def decorator(func):
+ func = ModelView.button(func)
+
+ @wraps(func)
+ def wrapper(*args, **kwargs):
+ pool = Pool()
+ model_data_obj = pool.get('ir.model.data')
+ action_obj = pool.get('ir.action')
+
+ func(*args, **kwargs)
+
+ module, fs_id = action.split('.')
+ action_id = action_obj.get_action_id(
+ model_data_obj.get_id(module, fs_id))
+ return action_id
+ return wrapper
+ return decorator
diff --git a/trytond/res/request.xml b/trytond/res/request.xml
index 278ebb7edd..828a822905 100644
--- a/trytond/res/request.xml
+++ b/trytond/res/request.xml
@@ -51,16 +51,13 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
-
+