Repository
OCA/odoo-pim · module folder · Try on Runboat
Module version
1.1.3
Category
Generic Modules/Others
Folder size
0.33 MB
License
AGPL-3
Application
No
Auto-installable
No
Website
https://github.com/OCA/odoo-pim
Last tracking update
2026-08-07 09:06:36
Authors
Akretion, Odoo Community Association (OCA)
Maintainers
Akretion, Odoo Community Association (OCA)
Committers
Jordi Ballester Alomar, Miquel Raïch, AaronHForgeFlow, Weblate, OCA-git-bot, oca-ci
Odoo dependencies
odoo/odoo:
- web
Python dependencies
unidecode
System dependencies
None
Required by
product_attribute_set, website_attribute_set
Description
This module allows the user to create Attributes to any model. This is a
basic module in the way that **it does not provide views to display
these new Attributes.**

Each Attribute created will be related to an **existing field** (in case
of a *"native"* Attribute) or to a newly **created field** (in case of a
*"custom"* Attribute).

A *"custom"* Attribute can be of any type : Char, Text, Boolean, Date,
Binary... but also Many2one or Many2many.

In case of m2o or m2m, these attributes can be related to **custom
options** created for the Attribute, or to **existing Odoo objects**
from other models.

Last but not least an Attribute can be **serialized** using the Odoo SA
module
[base_sparse_field](https://github.com/odoo/odoo/tree/16.0/addons/base_sparse_field)
. It means that all the serialized attributes will be stored in a single
"JSON serialization field" and will not create new columns in the
database (and better, it will not create new SQL tables in case of
Many2many Attributes), **increasing significantly the requests speed**
when dealing with thousands of Attributes.

Code Analysis

Views touched (14)
XML IDNameModelTypeStatus
attribute_attribute_form_view attribute.attribute.form attribute.attribute form New
attribute_attribute_tree_view attribute.attribute.list attribute.attribute list New
attribute_group_form_view attribute.group form New
attribute_group_search_view attribute.group search New
attribute_group_tree_view attribute.group list New
attribute_option_form_popup_view attribute.option.form.popup attribute.option form New
attribute_option_form_view attribute.option.form attribute.option form New
attribute_option_tree_view attribute.option.list attribute.option list New
attribute_option_wizard_form_view attribute.option.wizard attribute.option.wizard form New
attribute_set_form_view attribute.set.form attribute.set form New
attribute_set_tree_view attribute.set.list attribute.set list New
view_attribute_attribute_search attribute.attribute.list attribute.attribute search New
view_attribute_option_search attribute.option.list attribute.option search New
view_attribute_set_search attribute.set.list attribute.set search New
HTTP endpoints (0)

No HTTP endpoints found for this module.

Models touched (8)

New fields (14)
  • allowed_attribute_set_ids Many2many → attribute.set
    comodel_name='attribute.set' compute='_compute_allowed_attribute_set_ids'
  • attribute_group_id Many2one → attribute.group
    ondelete='cascade' required=True args: 'attribute.group', 'Attribute Group'
  • attribute_set_ids Many2many → attribute.set
    column1='attribute_id' column2='attribute_set_id' comodel_name='attribute.set' relation='rel_attribute_set' string='Attribute Sets'
  • attribute_type Selection
    args: [('char', 'Char'), ('text', 'Text'), ('select', 'Select'), ('multiselect', 'Multiselect'), ('boolean', 'Boolean'), ('integer', 'Integer'), ('float', 'Float'), ('date', 'Date'), ('datetime', 'Datetime'), ('binary', 'Binary (file)'), ('image', 'Image')]
  • create_date Datetime
    readonly=True args: 'Created date'
  • field_id Many2one → ir.model.fields
    ondelete='cascade' required=True args: 'ir.model.fields', 'Ir Model Fields'
  • nature Selection
    default='custom' required=True string='Attribute Nature' args: [('custom', 'Custom'), ('native', 'Native')]
  • option_ids One2many → attribute.option
    args: 'attribute.option', 'attribute_id', 'Attribute Options'
  • relation_model_id Many2one → ir.model
    ondelete='cascade' args: 'ir.model', 'Relational Model'
  • required_on_views Boolean
    help='If activated, the attribute will be mandatory on the views, but not in the database' args: 'Required (on views)'
  • sequence Integer
    help="The attribute's order in his group" args: 'Sequence in Group'
  • sequence_group Integer
    help='The sequence of the group' related='attribute_group_id.sequence' store='True' args: 'Sequence of the Group'
  • serialized Boolean
    help="If serialized, the attribute's field will be stored in the serialization\n field 'x_custom_json_attrs' (i.e. a JSON containing all the serialized\n fields values) instead of creating a new SQL column for this\n attribute's field. Useful to increase speed requests if creating a\n high number of attributes."
  • widget Char
    help='Specify widget to add to the field on the views.'
Public methods (9)
  • button_add_options(self)
  • copy(self, default=None)
    Ensure unique name when duplicating attribute.
  • create(self, vals_list)
    @api.model_create_multi
    Create an attribute.attribute - In case of a new "custom" attribute, a new field object 'ir.model.fields' will be created as this model "_inherits" 'ir.model.fields'. So we need to add here the mandatory 'ir.model.fields' instance's attributes to the new 'attribute.attribute'. - In case of a new "native" attribute, it will be linked to an existing field object 'ir.model.fields' (through "field_id") that cannot be modified. That's why we remove all the 'ir.model.fields' instance's attributes values from `vals` before creating our new 'attribute.attribute'.
  • onchange_attribute_type(self)
    @api.onchange('attribute_type')
  • onchange_field_description(self)
    @api.onchange('field_description')
  • onchange_model_id(self)
    @api.onchange('model_id')
  • onchange_name(self)
    @api.onchange('name')
  • unlink(self)
    Delete the Attribute's related field when deleting a custom Attribute
  • write(self, vals)

New fields (4)
  • attribute_ids One2many → attribute.attribute
    args: 'attribute.attribute', 'attribute_group_id', 'Attributes'
  • model_id Many2one → ir.model
    ondelete='cascade' required=True args: 'ir.model', 'Model'
  • name Char
    required=True translate=True
  • sequence Integer
    help="The Group order in his attribute's Set" args: 'Sequence in Set'
Public methods (0)

No public methods.

New fields (5)
  • attribute_id Many2one → attribute.attribute
    ondelete='cascade' required=True args: 'attribute.attribute', 'Product Attribute'
  • name Char
    required=True translate=True
  • relation_model_id Many2one → ir.model
    ondelete='cascade' related='attribute_id.relation_model_id' args: 'ir.model', 'Relational Model'
  • sequence Integer
  • value_ref Reference
    selection='_selection_model_list' string='Reference'
Public methods (0)

No public methods.

New fields (2)
  • attribute_id Many2one → attribute.attribute
    default=<expr> ondelete='cascade' required=True args: 'attribute.attribute', 'Product Attribute'
  • option_ids Many2many → attribute.option
    string='Attribute Options' args: 'attribute.option'
Public methods (3)
  • create(self, vals_list)
    @api.model_create_multi
  • get_views(self, views, options=None)
    @api.model
  • validate(self)

New fields (8)
  • attribute_ids Many2many → attribute.attribute
    column1='attribute_set_id' column2='attribute_id' comodel_name='attribute.attribute' relation='rel_attribute_set' string='Attributes'
  • child_ids One2many → attribute.set
    comodel_name='attribute.set' inverse_name='parent_id' string='Child Sets'
  • complete_attribute_ids Many2many → attribute.attribute
    comodel_name='attribute.attribute' compute='_compute_complete_attribute_ids' recursive=True string='All Attributes (inherited)'
  • model Char
    help='This is a technical field in order to build filters on this one to avoidaccess on ir.model' related='model_id.model' store=True string='Model Name'
  • model_id Many2one → ir.model
    ondelete='cascade' required=True args: 'ir.model', 'Model'
  • name Char
    required=True translate=True
  • parent_id Many2one → attribute.set
    comodel_name='attribute.set' domain="[('model_id', '=', model_id)]" index=True ondelete='restrict' string='Parent Set'
  • parent_path Char
    index=True
Public methods (0)

No public methods.

New fields (1)
  • attribute_set_id Many2one → attribute.set
    domain=<expr> args: 'attribute.set', 'Attribute Set'
Public methods (2)
  • get_view(self, view_id=None, view_type='form', **options)
  • remove_native_fields(self, eview)
    @api.model
    Remove native fields related to native attributes from eview

New fields (0)

No new fields.

Public methods (0)

No public methods.

New fields (0)

No new fields.

Public methods (0)

No public methods.

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…

Loading…