Base tags implementation for Odoo
Consists of set of modules to add tags to standard Odoo models.
- account.invoice model
- product.product model
- Odoo version 7.0: works fine
- Odoo version 8.0 and higher: not tested
To add tags to your model You need to folow folowing simple steps:
-
Add
base_tags
module as dependency for your module -
Use inherit from
"res.tag.mixin"
to get tags functionality to Your model, like:class Product(orm.Model): _name = "product.product" _inherit = ["product.product", "res.tag.mixin"] Product()
-
Add record to taggable models registry:
<record model="res.tag.model" id="res_tag_model_product_product"> <field name="name">Product</field> <field name="model">product.product</field> </record>
-
Now You can use
tag_ids
field in Your views for Your model:- search view:
<field name="tag_ids" string="Tag" filter_domain="['|',('tag_ids.name','ilike',self),('tag_ids.code','ilike',self)]"/> <field name="no_tag_id" string="No tag"/> <!-- For invers searching (items that do not contain tag)-->
- tree view:
<field name="tag_ids" widget="many2many_tags" placeholder="Tags..."/>
- form view:
<field name="tag_ids" widget="many2many_tags" placeholder="Tags..." context="{'default_model': 'product.product'}"/>
Pay attention on context field. This will allow to avoid tag form popup when adding tag from form field
- custom widget to show help/comment on tags mous over
- ability to show tags same in form view and in tree/list view
- make tags colored (any tag could have ovn color to fill backround in)