The fields objects are responsible for creating their column/table and indexes.
The methods that update the schema are overridden to handle cases specific to
each type of field.
Simplify the API as much as possible, and delegate all the implementation
details to the models `ir.model`, `ir.model.fields`, `ir.model.constraint` and
`ir.model.relation`.
When using read_group() and grouping by many2one fields, the many2one groupby
fields get updated from an integer id to a tuple from name_get() at the end
of the method.
e.g.: {'user_id': 1, ...} -> {'user_id': (1, u'Administrator'), ...}
To do this, it reads the many2one field by browsing on self.
When self is a model with _auto = False (typically an SQL view), searching by
id can be costly as the id column may not have usual properties for performance
(in some cases a full computation of the table is required to look up 1 id).
With the user who is trying to access and the record they are trying to access
to.
This way it is easier to understand the reason of the error.
Do not show record and user ids in the popup as it is a technical information.
Closes#13030
`model` field of `ir.model` may be used as related stored field.
Marking it as modified force recomputation of these, even no change
occurs (by definition).
This removal has led to a necessary refactoring:
- make the setup of field attributes extensible;
- make the instantiation of custom fields extensible;
- delegate model and field reflection to `ir.model` and `ir.model.fields`;
- move the implementation of sparse and serialized fields to module `base_sparse_field`;
split fields_view_get() and used an abstact mixin class in place of of FormatAddress
[IMP] base: added a m2o field (ir.ui.view) on res.country to decide the layout of the form view to input addresses.
The dictionary `_group_by_full` is replaced by a field parameter `group_expand`
that is assigned to the method name. The API of the method has been simplified
as well:
@api.multi
def _read_group_stage_ids(self, domain, read_group_order=None, access_rights_uid=None):
# the stages are given by self.ids (wrong model);
# read_group_order is the order given to read_group() on self;
# return stages.name_get(), {stage.id: stage.fold)
_group_by_full = {'stage_id': _read_group_stage_ids}
is now written:
stage_id = fields.Many2one(..., group_expand='_read_group_stage_ids')
@api.model
def _read_group_stage_ids(self, stages, domain, order):
# stages is a recordset;
# order is the order to use on stages' model;
# return a recordset which is a superset of stages
RecordSets were not preserving order when combined
with AND/OR set operators. Order was lost as well
through mapped().
This caused various recurring "heisenbugs" during
tests executions on runbot, specifically comming
in the test of stock_landed_costs.
Using OrderedSets instead of basic Sets to resolve
these operation avoids the indetermination.
This required an implementation of __or__ / __and__
for OrderedSet.