summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorxmo-odoo <xmo@odoo.com>2018-05-09 09:45:29 +0200
committerGitHub <noreply@github.com>2018-05-09 09:45:29 +0200
commit020906659e55bd41a07ab0e4e79da903af7b50c1 (patch)
tree8edbbb101877fbf9c08b281f0f2d4e6f3fbbd329 /odoo
parentf2e105eeca409e55be0408edcc986b39fd026094 (diff)
[FIX] orm: "relate" binding type on actions
When ir.values was removed and the "action" ir.values were merged directly into the actions themselves, "client_action_relate" was discarded as unused (and possibly too similar to client_action_multi?). *However*: * it was actually used implicitly as "relate" was the default key2 of the <act_window> XML tag * and it had a crucial difference from client_action_multi: client_action_multi is shown on both form and list views by default and only on list if multi=True, whereas relate is shown on *either* the form or list view (tree if multi else form) This means without relate the actions which should be only visible on the form view are now on both list and tree, which leads to overpopulated `Action` menus and odd behaviours (e.g. actions relying active_id on lists, which id do they get and why?) => reintroduce relate as "action_form_only" for the specific case of multi=False and either no key2 or a key2 of client_action_relate. If multi=True then binding_type=action. Fixes #20124 Followup: Task 1843603 to remove #multi and redundancy
Diffstat (limited to 'odoo')
-rw-r--r--odoo/addons/base/ir/ir_actions.py1
-rw-r--r--odoo/models.py4
-rw-r--r--odoo/tools/convert.py7
3 files changed, 10 insertions, 2 deletions
diff --git a/odoo/addons/base/ir/ir_actions.py b/odoo/addons/base/ir/ir_actions.py
index 646615cb593..862d288ac5b 100644
--- a/odoo/addons/base/ir/ir_actions.py
+++ b/odoo/addons/base/ir/ir_actions.py
@@ -34,6 +34,7 @@ class IrActions(models.Model):
binding_model_id = fields.Many2one('ir.model', ondelete='cascade',
help="Setting a value makes this action available in the sidebar for the given model.")
binding_type = fields.Selection([('action', 'Action'),
+ ('action_form_only', "Form-only"),
('report', 'Report')],
required=True, default='action')
diff --git a/odoo/models.py b/odoo/models.py
index 1b0207e9eb9..202887a31be 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -1391,6 +1391,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
resaction = [action
for action in bindings['action']
if view_type == 'tree' or not action.get('multi')]
+ resrelate = []
+ if view_type == 'form':
+ resrelate = bindings['action_form_only']
for res in itertools.chain(resreport, resaction):
res['string'] = res['name']
@@ -1398,6 +1401,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
result['toolbar'] = {
'print': resreport,
'action': resaction,
+ 'relate': resrelate,
}
return result
diff --git a/odoo/tools/convert.py b/odoo/tools/convert.py
index 59e87d6ee32..97fb2be7330 100644
--- a/odoo/tools/convert.py
+++ b/odoo/tools/convert.py
@@ -427,11 +427,14 @@ form: module.record_id""" % (xml_id,)
if rec.get('target'):
res['target'] = rec.get('target','')
+ if rec.get('multi'):
+ res['multi'] = safe_eval(rec.get('multi', 'False'))
if src_model:
res['binding_model_id'] = self.env['ir.model']._get(src_model).id
res['binding_type'] = 'report' if rec.get('key2') == 'client_print_multi' else 'action'
- if rec.get('multi'):
- res['multi'] = safe_eval(rec.get('multi', 'False'))
+ if rec.get('key2') in (None, 'client_action_relate'):
+ if not res.get('multi'):
+ res['binding_type'] = 'action_form_only'
id = self.env['ir.model.data']._update('ir.actions.act_window', self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
self.idref[xml_id] = int(id)