Commit Graph
10 Commits
Author SHA1 Message Date
Raphael Collet aa0cdacced [FIX] core: related field attributes
A related field copies the attributes from its target field, except for
the attributes defined on the related field itself.  The implementation
of this feature was not working properly for attributes with a truthy
default value.

closes odoo/odoo#79025

X-original-commit: dec4a7ec478fa02f19dee8c8426c88d17dc3c7f3
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-10-26 16:06:48 +00:00
Raphael Collet 1abe965b59 [IMP] core: keep field.related as a string
This mainly keeps field.related's type consistent.

On a registry with 296 modules, this saves 325 kilobytes of memory,
which is about 3% of the registry's memory footprint.
2021-05-10 14:29:42 +00:00
Raphael Collet 9afce4805f [IMP] core: reflect models, fields and selections in batch
This saves 4.5% of the total installation time.

X-original-commit: 8519064dce975af542ccd30dc14c56b9bb36d07b
2020-04-03 11:40:29 +00:00
Adrian Torres f0481392c6 [IMP] core: introduce mechanism for selection_add cleanup
- Let A and B be two different modules.
- A defines a required Selection field F of model M and B extends
  it through the `selection_add` argument.
- Create records of model M and have some of them have any of the
  options introduced by module B selected for field F.
- Uninstall module B.

The result will be records of Model M with an option for field F that no
longer exists, this makes the registry inconsistent and prone to
crashing (it is sufficient to access the form view of such a record to
trigger a crash).

This commit introduces a mechanism similar to the `ondelete` argument
found in Many2one fields, the argument name is the same but it's
different both in behaviour and in implementation.

The `ondelete` mechanism for Selection fields is enforced for **any**
Selection field with required set to `True`, this means that the
developer is required to set a cleanup behaviour for when their module
is uninstalled. For possible cleanup options, see fields.Selection's
docstring.

As far as implementation goes, everything is implemented in Python
unlike with Many2one fields where the behaviour is delegated to
PostgreSQL.

The `ondelete` setting will be processed during
`ir.model.fields.selection.unlink()` to ensure that the registry is left
in an appropriate state after module uninstall.
2020-03-30 13:42:04 +00:00
Lucas Perais (lpe) 8c8f328e29 [FIX] orm: fields x2m are not sortable
Before this commit, x2m fields were described as 'sortable'
This was odd since:
- When actually sorting on one of those fields through the webclient
the sorting was gibbrish
- Even the orm silently warned in the log that
the field was not a sql column and therefore was not sortable

After this commit, only a field which is column (and a few other conditions)
can be sorted

Task 1863492

closes odoo/odoo#46921

X-original-commit: dd3094378fc322447d1aef994f6bace3f0c24288
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-03-04 16:26:07 +00:00
Raphael Collet 2554d197ff [IMP] test_new_api: add subtests (to ease debugging)
closes odoo/odoo#40574

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-12-03 09:31:32 +00:00
Martin TrigauxandRaphaël Collet 7593b887df [REF] fields: use ir.model.fields.selection
The selection values of a selection field are now stored in database in the
model ir.model.fields.selection

This will allow to have a modular approche on selections and each selection
is now linked to the module that declared it.
Previously to this change, the selections were linked to the field, meaning
uninstalling a module had no impact on the selections stored on database.

With this change, the selections will now be translated in the correct module
(having an external id) and the records having a used selection will now be
reset to null.

closes odoo/odoo#30228

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>


Co-authored-by: Raphaël Collet <rco@odoo.com>
2019-08-19 11:44:34 +00:00
Raphael Collet 2b9d5f929c [FIX] base: avoid clash between field and method copy 2018-09-14 14:26:24 +02:00
qdp-odoo 84e4f6b08c [FIX] base: fixing test_new_api after previous commit.
New test introduced at https://github.com/odoo/odoo/commit/3214ca98206e5f99e2ab1d471ce1ef543057c9f6 tested the type of a column we changed from datetime to date in https://github.com/odoo/odoo/commit/01142701cc566b3084326af9649fd85db02b4220. Picked another datetime field to do the test
2017-04-11 08:39:34 +02:00
Raphael Collet 3214ca9820 [ADD] test_new_api: add checks on a model's schema 2017-02-22 15:16:34 +01:00