diff --git a/web_m2x_options/README.rst b/web_m2x_options/README.rst index be6e7603..abdd8803 100644 --- a/web_m2x_options/README.rst +++ b/web_m2x_options/README.rst @@ -61,7 +61,13 @@ New options A dictionary to link field value with a HTML color. This option has to be used with field_color. +``no_open_edit`` *boolean* (Default: value of ``no_open`` which is ``False`` if not set) + Causes a many2one not to offer to click through in edit mode, but well in read mode + +``open`` *boolean* (Default: ``False``) + + Makes many2many_tags buttons that open the linked resource ir.config_parameter options --------------------------- @@ -110,6 +116,6 @@ Your XML form view definition could contain:: Note ---- -Double check that you have no inherited view that remote ``options`` you set on a field ! -If nothing work, add a debugger in the first ligne of ``get_search_result method`` and enable debug mode in OpenERP. When you write something in a many2one field, javascript debugger should pause. If not verify your installation. +Double check that you have no inherited view that remove ``options`` you set on a field ! +If nothing works, add a debugger in the first line of ``get_search_result method`` and enable debug mode in OpenERP. When you write something in a many2one field, javascript debugger should pause. If not verify your installation. diff --git a/web_m2x_options/__openerp__.py b/web_m2x_options/__openerp__.py index 37b7dbf4..071166fd 100644 --- a/web_m2x_options/__openerp__.py +++ b/web_m2x_options/__openerp__.py @@ -7,6 +7,9 @@ 'base', 'web', ], + 'qweb': [ + 'static/src/xml/base.xml', + ], 'data': ['views/view.xml'], "author": "0k.io,Odoo Community Association (OCA)", "installable": True, diff --git a/web_m2x_options/static/src/js/form.js b/web_m2x_options/static/src/js/form.js index bc4d3beb..7342794e 100644 --- a/web_m2x_options/static/src/js/form.js +++ b/web_m2x_options/static/src/js/form.js @@ -336,6 +336,30 @@ openerp.web_m2x_options = function (instance) { return values; }) }, + + render_value: function() + { + var self = this; + return jQuery.when(this._super.apply(this, arguments)) + .then(function() + { + if(self.options.open) + { + self.$el.find('.oe_tag') + .css('cursor', 'pointer') + .click(function(e) + { + var id = parseInt(jQuery(this).attr('data-id')); + self.do_action({ + type: 'ir.actions.act_window', + res_model: self.field.relation, + views: [[false, 'form']], + res_id: id, + }); + }); + } + }); + }, }); }; diff --git a/web_m2x_options/static/src/xml/base.xml b/web_m2x_options/static/src/xml/base.xml new file mode 100644 index 00000000..9fbf425e --- /dev/null +++ b/web_m2x_options/static/src/xml/base.xml @@ -0,0 +1,13 @@ + + + + + jQuery(this).attr('t-if', '!(widget.options.no_open || widget.options.no_open_edit)'); + + + + + jQuery(this).attr('t-att-data-id', 'el[0]'); + + +