Holger Brunn
9 years ago
6 changed files with 163 additions and 0 deletions
-
53web_widget_one2many_tags/README.rst
-
3web_widget_one2many_tags/__init__.py
-
18web_widget_one2many_tags/__openerp__.py
-
BINweb_widget_one2many_tags/static/description/icon.png
-
79web_widget_one2many_tags/static/src/js/web_widget_one2many_tags.js
-
10web_widget_one2many_tags/views/templates.xml
@ -0,0 +1,53 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
=============================== |
||||
|
Tags widget for one2many fields |
||||
|
=============================== |
||||
|
|
||||
|
This module add a widget ``one2many_tags`` that looks and behaves like ``many2many_tags``, but works for one2many fields. |
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
To use this module, use ``widget="one2many_tags"`` on your field element. |
||||
|
|
||||
|
* 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/162/8.0 |
||||
|
|
||||
|
For further information, please visit: |
||||
|
|
||||
|
* https://www.odoo.com/forum/help-1 |
||||
|
|
||||
|
Bug Tracker |
||||
|
=========== |
||||
|
|
||||
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/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 <https://github.com/OCA/web/issues/new?body=module:%20web_widget_one2many_tags%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Holger Brunn <hbrunn@therp.nl> |
||||
|
|
||||
|
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. |
@ -0,0 +1,3 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Therp BV <http://therp.nl> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
@ -0,0 +1,18 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Therp BV <http://therp.nl> |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
{ |
||||
|
"name": "Tags widget for one2many fields", |
||||
|
"version": "8.0.1.0.0", |
||||
|
"author": "Therp BV,Odoo Community Association (OCA)", |
||||
|
"license": "AGPL-3", |
||||
|
"category": "Hidden/Dependency", |
||||
|
"summary": "Provides a widget similar to many2many_tags for one2many " |
||||
|
"fields", |
||||
|
"depends": [ |
||||
|
'web', |
||||
|
], |
||||
|
"data": [ |
||||
|
'views/templates.xml', |
||||
|
], |
||||
|
} |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1,79 @@ |
|||||
|
//-*- coding: utf-8 -*-
|
||||
|
//© 2016 Therp BV <http://therp.nl>
|
||||
|
//License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
|
||||
|
openerp.web_widget_one2many_tags = function(instance) |
||||
|
{ |
||||
|
openerp.web_widget_one2many_tags.FieldOne2ManyTags = |
||||
|
instance.web.form.FieldMany2ManyTags.extend({ |
||||
|
initialize_texttext: function() |
||||
|
{ |
||||
|
var self = this, |
||||
|
result = this._super.apply(this, arguments), |
||||
|
removeTag = result.ext.tags.removeTag; |
||||
|
result.plugins = 'tags arrow filter'; |
||||
|
result.ext.core.onSetInputData = function(e, data) |
||||
|
{ |
||||
|
this.input().val(data); |
||||
|
}; |
||||
|
result.filter = { |
||||
|
items: [] |
||||
|
}; |
||||
|
result.ext.arrow = { |
||||
|
onArrowClick: function(e) |
||||
|
{ |
||||
|
var context = {}, |
||||
|
key = _.str.sprintf( |
||||
|
'default_%s', self.field.relation_field) |
||||
|
context[key] = self.field_manager.datarecord.id; |
||||
|
self._search_create_popup('form', undefined, context); |
||||
|
}, |
||||
|
} |
||||
|
result.ext.tags.removeTag = function(tag) |
||||
|
{ |
||||
|
var id = tag.data("id"), |
||||
|
dataset = new instance.web.DataSet( |
||||
|
self, self.field.relation, self.build_context()); |
||||
|
dataset.unlink([id]); |
||||
|
return removeTag(tag); |
||||
|
}; |
||||
|
return result; |
||||
|
}, |
||||
|
initialize_content: function() |
||||
|
{ |
||||
|
var self = this, |
||||
|
result = this._super.apply(this, arguments); |
||||
|
if(!this.$text) |
||||
|
{ |
||||
|
return result; |
||||
|
} |
||||
|
this.$text.bind('tagClick', function(e, tag, value, callback) |
||||
|
{ |
||||
|
var popup = new instance.web.form.FormOpenPopup(self); |
||||
|
popup.show_element( |
||||
|
self.field.relation, value.id, self.build_context(), |
||||
|
{ |
||||
|
title: instance.web._t("Open: ") + value.name, |
||||
|
readonly: self.get("effective_readonly"), |
||||
|
}); |
||||
|
popup.on('write_completed', self, function() |
||||
|
{ |
||||
|
popup.dataset.name_get(popup.dataset.ids) |
||||
|
.then(function(names) |
||||
|
{ |
||||
|
_(names).each(function(name) |
||||
|
{ |
||||
|
value.name = name[1]; |
||||
|
callback(value, true); |
||||
|
}) |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
return result; |
||||
|
}, |
||||
|
}); |
||||
|
instance.web.form.widgets.add( |
||||
|
'one2many_tags', |
||||
|
'instance.web_widget_one2many_tags.FieldOne2ManyTags' |
||||
|
); |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<openerp> |
||||
|
<data> |
||||
|
<template id="assets_backend" name="web_widget_one2many_tags assets" inherit_id="web.assets_backend"> |
||||
|
<xpath expr="." position="inside"> |
||||
|
<script type="text/javascript" src="/web_widget_one2many_tags/static/src/js/web_widget_one2many_tags.js"></script> |
||||
|
</xpath> |
||||
|
</template> |
||||
|
</data> |
||||
|
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue