diff --git a/web_one2many_list_action/README.rst b/web_one2many_list_action/README.rst new file mode 100644 index 00000000..c44d13d8 --- /dev/null +++ b/web_one2many_list_action/README.rst @@ -0,0 +1,85 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +======================== +Web One2many List Action +======================== + +This module extends the list view used for one2many fields inside form views to +use the 'tree_but_open' interface to define actions for rows. + +To use this just specify a 'tree_but_open' action on the target model of the +one2many field relation. + +Example +:: + + + + message_index_list_view_delegate_open + + action = object.button_popup_delegate() + + + + + message.index + tree_but_open + message_index_list_view + + + + +Installation +============ + +To install this module, just follow basic steps to install an Odoo module. + + +Configuration +============= + +No configuration needed. + +Usage +===== + +To use this module, you need to: + +* go to ... + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/web/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Peter Hahn + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/web_one2many_list_action/__init__.py b/web_one2many_list_action/__init__.py new file mode 100644 index 00000000..40a96afc --- /dev/null +++ b/web_one2many_list_action/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/web_one2many_list_action/__openerp__.py b/web_one2many_list_action/__openerp__.py new file mode 100644 index 00000000..942a9492 --- /dev/null +++ b/web_one2many_list_action/__openerp__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +{ + 'name': 'web_one2many_list_action', + 'summary': 'Enable tree_but_open action for One2ManyListView rows.', + 'version': '8.0.1.0.0', + 'author': 'initOS GmbH, Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'auto_install': False, + 'depends': [ + 'web', + ], + 'data': [ + 'assets.xml', + ], + 'images': [], +} diff --git a/web_one2many_list_action/assets.xml b/web_one2many_list_action/assets.xml new file mode 100644 index 00000000..e194688c --- /dev/null +++ b/web_one2many_list_action/assets.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/web_one2many_list_action/static/description/icon.png b/web_one2many_list_action/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/web_one2many_list_action/static/description/icon.png differ diff --git a/web_one2many_list_action/static/src/js/views.js b/web_one2many_list_action/static/src/js/views.js new file mode 100644 index 00000000..6d6182e9 --- /dev/null +++ b/web_one2many_list_action/static/src/js/views.js @@ -0,0 +1,42 @@ +/*global openerp, _, $ */ + +openerp.web_one2many_list_action = function (instance) { + + instance.web.form.One2ManyListView.include({ + do_activate_record: function(index, id) { + var self = this; + var _func = self._super + var _args = arguments + + var local_context = { + active_model: self.o2m.field.relation, + active_id: id, + active_ids: [id] + }; + var ctx = instance.web.pyeval.eval( + 'context', new instance.web.CompoundContext( + self.o2m.build_context(), local_context)); + + this.rpc('/web/treeview/action', { + id: id, + model: self.o2m.field.relation, + context: ctx + }).then(function (actions) { + if (actions.length) { + // execute action + var action = actions[0][2]; + var c = new instance.web.CompoundContext(local_context).set_eval_context(ctx); + if (action.context) { + c.add(action.context); + } + action.context = c; + self.do_action(action); + } else { + // if no action configured apply default behaviour + _func.apply(self, _args); + } + }); + }, + }); + +}