Browse Source

support 'open' on many2many_tags

[ADD] support 'no_open_edit' on many2one
[FIX] typos
pull/418/head
Holger Brunn 9 years ago
committed by Laurent Mignon
parent
commit
53e964cfa8
  1. 10
      web_m2x_options/README.rst
  2. 3
      web_m2x_options/__openerp__.py
  3. 24
      web_m2x_options/static/src/js/form.js
  4. 13
      web_m2x_options/static/src/xml/base.xml

10
web_m2x_options/README.rst

@ -61,7 +61,13 @@ New options
A dictionary to link field value with a HTML color. A dictionary to link field value with a HTML color.
This option has to be used with field_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 ir.config_parameter options
--------------------------- ---------------------------
@ -110,6 +116,6 @@ Your XML form view definition could contain::
Note 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.

3
web_m2x_options/__openerp__.py

@ -7,6 +7,9 @@
'base', 'base',
'web', 'web',
], ],
'qweb': [
'static/src/xml/base.xml',
],
'data': ['views/view.xml'], 'data': ['views/view.xml'],
"author": "0k.io,Odoo Community Association (OCA)", "author": "0k.io,Odoo Community Association (OCA)",
'installable': False, 'installable': False,

24
web_m2x_options/static/src/js/form.js

@ -336,6 +336,30 @@ openerp.web_m2x_options = function (instance) {
return values; 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,
});
});
}
});
},
}); });
}; };

13
web_m2x_options/static/src/xml/base.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-extend="FieldMany2One">
<t t-jquery="a.oe_m2o_cm_button">
jQuery(this).attr('t-if', '!(widget.options.no_open || widget.options.no_open_edit)');
</t>
</t>
<t t-extend="FieldMany2ManyTag">
<t t-jquery="span.oe_tag">
jQuery(this).attr('t-att-data-id', 'el[0]');
</t>
</t>
</templates>
Loading…
Cancel
Save