diff --git a/product_tags/__init__.py b/product_tags/__init__.py index 9e90ae0380..c73ce3ddcd 100644 --- a/product_tags/__init__.py +++ b/product_tags/__init__.py @@ -2,6 +2,7 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2013 Julius Network Solutions SARL +# Copyright (c) 2019 Matteo Bilotta # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,4 +19,4 @@ # # -from . import product +from . import models diff --git a/product_tags/__manifest__.py b/product_tags/__manifest__.py index 522c699dff..0fc00590e9 100644 --- a/product_tags/__manifest__.py +++ b/product_tags/__manifest__.py @@ -3,6 +3,7 @@ # OpenERP, Open Source Management Solution # Copyright (C) 2013 Julius Network Solutions SARL # Copyright (C) 2015 credativ ltd. +# Copyright (c) 2019 Matteo Bilotta # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -21,19 +22,19 @@ { "name": "Product Tags", - "version": "10.0.1.0.1", + "version": "12.0.1.1.0", "author": "Julius Network Solutions", "website": "http://julius.fr", - "category": "Sales Management", + "category": "Sales", "depends": [ 'product', - 'sale', + 'sale' ], 'license': 'AGPL-3', - "demo": [], "data": [ 'security/ir.model.access.csv', - 'product_view.xml', - ], - 'installable': False, + + 'views/product_tag_view.xml', + 'views/product_template_view.xml' + ] } diff --git a/product_tags/doc/changelog.rst b/product_tags/doc/changelog.rst index 3a61d0fca9..df242417fb 100644 --- a/product_tags/doc/changelog.rst +++ b/product_tags/doc/changelog.rst @@ -1,4 +1,12 @@ +`1.1.0` +------- + +- **Successful migration to Odoo 12.** +- Improved tag searching algorithm. +- Enhanced tag views for a better UX. + `1.0.1` +------- - **Fix:** issue with search for non-existent tags diff --git a/product_tags/i18n/it.po b/product_tags/i18n/it.po new file mode 100644 index 0000000000..0f51f6e8f7 --- /dev/null +++ b/product_tags/i18n/it.po @@ -0,0 +1,147 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_tags +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0+e-20190417\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-06-21 13:41+0000\n" +"PO-Revision-Date: 2019-06-21 15:42+0200\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: it\n" +"X-Generator: Poedit 2.2.3\n" + +#. module: product_tags +#: model_terms:ir.ui.view,arch_db:product_tags.product_tag_form_view +msgid "Accessories & Supplies" +msgstr "Accessori & Forniture" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__active +msgid "Active" +msgstr "Attivo" + +#. module: product_tags +#: model_terms:ir.ui.view,arch_db:product_tags.product_tag_search_view +msgid "Archived" +msgstr "Archiviati" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__child_ids +msgid "Child tags" +msgstr "Tag figli" + +#. module: product_tags +#: model_terms:ir.actions.act_window,help:product_tags.product_tag_action +msgid "Click to create a new product tag." +msgstr "Clicca per creare un nuovo tag di prodotto." + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__color +msgid "Color index" +msgstr "Indice colore" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: product_tags +#: model_terms:ir.ui.view,arch_db:product_tags.product_tag_form_view +msgid "Electronics" +msgstr "Elettronica" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__id +msgid "ID" +msgstr "ID" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__image +msgid "Image" +msgstr "Immagine" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__parent_id +msgid "Parent tag" +msgstr "Tag superiore" + +#. module: product_tags +#: model:ir.model,name:product_tags.model_product_template +msgid "Product Template" +msgstr "Modello prodotto" + +#. module: product_tags +#: model:ir.model,name:product_tags.model_product_tag +msgid "Product tags" +msgstr "Tag prodotti" + +#. module: product_tags +#: model:ir.model.fields,field_description:product_tags.field_product_tag__name +msgid "Tag Name" +msgstr "Nome tag" + +#. module: product_tags +#: model:ir.actions.act_window,name:product_tags.product_tag_action +#: model:ir.model.fields,field_description:product_tags.field_product_product__tag_ids +#: model:ir.model.fields,field_description:product_tags.field_product_template__tag_ids +#: model:ir.ui.menu,name:product_tags.product_tag_menu_sale +#: model_terms:ir.ui.view,arch_db:product_tags.product_template_search_view +msgid "Tags" +msgstr "Tag" + +#. module: product_tags +#: model_terms:ir.ui.view,arch_db:product_tags.product_template_form_view +msgid "Tags..." +msgstr "Tags..." + +#. module: product_tags +#: model:ir.model.fields,help:product_tags.field_product_tag__active +msgid "The active field allows you to hide the tag without removing it." +msgstr "Il campo \"Attivo\" ti consente di nascondere il tag prodotto senza rimuoverlo fisicamente." + +#. module: product_tags +#: model_terms:ir.actions.act_window,help:product_tags.product_tag_action +msgid "" +"With product tags you can categorize your products\n" +" regardless of the category they belong to." +msgstr "" +"Con i tag prodotti puoi categorizzare i tuoi prodotti\n" +" indipendentemente dalla categoria a cui appartengono." + +#. module: product_tags +#: code:addons/product_tags/models/product.py:45 +#, python-format +msgid "You cannot create recursive product tags." +msgstr "Non puoi creare tag prodotti ricorsivi." diff --git a/product_tags/models/__init__.py b/product_tags/models/__init__.py new file mode 100644 index 0000000000..241c24657c --- /dev/null +++ b/product_tags/models/__init__.py @@ -0,0 +1,22 @@ +# +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013 Julius Network Solutions SARL +# Copyright (c) 2019 Matteo Bilotta +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# + +from . import product diff --git a/product_tags/product.py b/product_tags/models/product.py similarity index 53% rename from product_tags/product.py rename to product_tags/models/product.py index 82187d07be..5644b5c176 100644 --- a/product_tags/product.py +++ b/product_tags/models/product.py @@ -3,6 +3,7 @@ # OpenERP, Open Source Management Solution # Copyright (C) 2013 Julius Network Solutions SARL # Copyright (C) 2015 credativ ltd. +# Copyright (c) 2019 Matteo Bilotta # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,51 +19,67 @@ # along with this program. If not, see . # # -from openerp import api -from openerp import fields -from openerp import models +from odoo import _, api, fields, models +from odoo.osv import expression +from odoo.exceptions import ValidationError class ProductTag(models.Model): - _description = 'Product Tags' - _name = "product.tag" + _name = 'product.tag' + _description = "Product tags" + _order = 'name' + _parent_order = 'name' + _parent_store = True name = fields.Char('Tag Name', required=True, translate=True) active = fields.Boolean(help='The active field allows you to hide the tag without removing it.', default=True) + color = fields.Integer(string="Color index", default=0) + image = fields.Binary(sintrg="Image") + parent_id = fields.Many2one(string='Parent Tag', comodel_name='product.tag', index=True, ondelete='cascade') child_ids = fields.One2many(string='Child Tags', comodel_name='product.tag', inverse_name='parent_id') - parent_left = fields.Integer('Left Parent', index=True) - parent_right = fields.Integer('Right Parent', index=True) + parent_path = fields.Char(index=True) - image = fields.Binary('Image') - - _parent_store = True - _parent_order = 'name' - _order = 'parent_left' + @api.constrains('parent_id') + def _check_parent_id(self): + if not self._check_recursion(): + raise ValidationError(_("You cannot create recursive product tags.")) @api.multi def name_get(self): - """ Return the tags' display name, including their direct parent. """ - res = {} - for record in self: - current = record - name = current.name - while current.parent_id: - name = '%s / %s' % (current.parent_id.name, name) + res = [] + + for category in self: + names = [] + current = category + + while current: + names.append(current.name) current = current.parent_id - res[record.id] = name - return list(res.items()) + res.append((category.id, ' / '.join(reversed(names)))) + + return res @api.model - def name_search(self, name, args=None, operator='ilike', limit=100): + def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): args = args or [] + if name: - # Be sure name_search is symetric to name_get - name = name.split(' / ')[-1] - args = [('name', operator, name)] + args - tags = self.search(args, limit=limit) - return tags.name_get() + parent_ids = [] + parent_domain = [] + + for tag in map(lambda t: t.strip(), name.split('/')): + name_domain = expression.AND([[('name', operator, tag)], parent_domain]) + parent_ids = self._search(name_domain, limit=limit, access_rights_uid=name_get_uid) + parent_domain = [('parent_id', 'in', parent_ids)] + + browse_domain = expression.OR([[('id', 'in', parent_ids)], parent_domain]) + args = expression.AND([browse_domain, args]) + + tag_ids = self._search(args, limit=limit, access_rights_uid=name_get_uid) + + return self.browse(tag_ids).name_get() class ProductTemplate(models.Model): diff --git a/product_tags/product_view.xml b/product_tags/product_view.xml deleted file mode 100644 index 7e601902f5..0000000000 --- a/product_tags/product_view.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - product.tag.view.form - product.tag - -
- - - - - - - - -
-
-
- - - product.tag.view.tree - product.tag - child_ids - - - - - - - - - Product Tags - product.tag - - - - - - - - - - product.tag.view.search - product.tag - - - - - - - - Product Tags - ir.actions.act_window - product.tag - form - tree,form - - - - - - - product.template.tag.view.search - product.template - - - - - - - - - - product.template.view.form - product.template - - - - - - - - - - - - Product Template Tag Kanban - product.template - - -
-
    -
  • -
-
-
-
- - -
-
diff --git a/product_tags/security/ir.model.access.csv b/product_tags/security/ir.model.access.csv index b3f1fc3cc9..cf961d9322 100644 --- a/product_tags/security/ir.model.access.csv +++ b/product_tags/security/ir.model.access.csv @@ -1,4 +1,3 @@ -"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" -"access_product_tag_all","product_tag_all","model_product_tag",,1,0,0,0 -"access_product_tag_user","product_tag_user","model_product_tag","base.group_user",1,1,1,0 -"access_product_tag_product_manager","product_tag_product_manager","model_product_tag","product.group_mrp_properties",1,1,1,1 +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_tag_user,product.tag.user,model_product_tag,base.group_user,1,0,0,0 +access_product_tag_manager,product.tag.manager,model_product_tag,base.group_system,1,1,1,1 diff --git a/product_tags/static/src/img/icon.png b/product_tags/static/src/img/icon.png deleted file mode 100644 index e07cdd3f72..0000000000 Binary files a/product_tags/static/src/img/icon.png and /dev/null differ diff --git a/product_tags/views/product_tag_view.xml b/product_tags/views/product_tag_view.xml new file mode 100644 index 0000000000..536382d5e5 --- /dev/null +++ b/product_tags/views/product_tag_view.xml @@ -0,0 +1,78 @@ + + + + + + product.tag.form + product.tag + +
+ +
+ +
+ +
+
+ +
+
+
+
+ + + product.tag.tree + product.tag + + + + + + + + + product.tag.search + product.tag + + + + + + + + + + + + Tags + product.tag + form + tree,form + + +

+ Click to create a new product tag. +

+

+ With product tags you can categorize your products + regardless of the category they belong to. +

+
+
+ + + +
diff --git a/product_tags/views/product_template_view.xml b/product_tags/views/product_template_view.xml new file mode 100644 index 0000000000..a75ac55133 --- /dev/null +++ b/product_tags/views/product_template_view.xml @@ -0,0 +1,46 @@ + + + + + + product.template.form + product.template + + + +
+ +
+
+
+
+ + + product.template.kanban + product.template + + + + + + + + + + + + product.template.search + product.template + + + + + + + + + +