Commit Graph

180 Commits

Author SHA1 Message Date
Raphael Collet 8f38a7806a [IMP] enable loading custom models/fields and views from module data files
Loading views for custom models from module data files was not possible because
custom models and fields were introduced into the registry after all modules
were loaded.  As a consequence, the view architecture did not pass the checks.

This patch takes a different approach: custom models and fields are loaded
early on in the registry, so that views can be validated.  The trick is to take
special care of relational custom fields: we skip them if their comodel does
not appear in the registry.  This allows to install and upgrade modules that
create/modify custom models, fields and views for them.
2014-12-19 13:57:08 +01:00
Samus CTO 55fa50891d [FIX] Use _unknown model for missing models in relation fields
During a migration of database, it is possible that some custom field
("x_", state is 'manual') are relational to model from a module that is
not provided.

Note: this used to work in Odoo 7.0 but crashed in 8.0.

Closes #3877
2014-12-04 20:58:46 +01:00
Raphael Collet 2052c16d21 [FIX] ir_model: on a custom model, _rec_name should be 'x_name' if it exists 2014-11-17 12:05:37 +01:00
Raphael Collet 3c203703db [FIX] ir_model: always setup models before calling _auto_init() 2014-11-13 14:54:04 +01:00
Raphael Collet 3adbb49ec0 [FIX] ir_model: fix create/update/delete custom fields
Creating custom fields would crash on a model that has a related field without
string.  The crash was caused by the field not being set up, and method
BaseModel._field_create() violating a non-null constraint on the field string.
This has been fixed by setting up fields before updating ir_model_fields.

Deleting a custom field could also cause trouble when that field is inherited
in a child model.  In that case, the registry was simply no longer consistent.
The fix is to reload completely the registry.

The modification of custom fields was not reflected on field objects.  The fix
applies changes on fields before updating columns accordingly.
2014-11-04 14:52:13 +01:00
Xavier Morel 4d2b24adcb [ADD] Stripe-style APIDoc: content 2014-10-27 17:23:16 +01:00
Denis Ledoux 1c6c289f7b [FIX] api: clear environments on module installation 2014-10-02 17:46:25 +02:00
Raphael Collet 24f26c0eeb [FIX] ir_models: fix registry when we add/remove/modify a custom model/field 2014-09-24 15:30:37 +02:00
Martin Trigaux f0c3856be2 [IMP] gamification: allow to select fields of inherited models 2014-09-18 11:12:15 +02:00
Martin Trigaux 423a9f3011 [ADD] base: list of inherited models on a ir.model
This field is needed to retrieve the list of inherited fields (instead of only the fields of a current model) of a model using domain such as ('model_id', 'in', model.inherited_model_ids) on ir.model.fields
2014-09-18 11:12:15 +02:00
Denis Ledoux 51e7e03502 [MERGE] forward port of branch saas-5 up to 163d7f5 2014-09-15 14:25:02 +02:00
Olivier Dony ddc78626e1 [IMP] ir.model:.fields allow setting ondelete=restrict foncustom fields 2014-09-12 17:51:56 +02:00
Christophe Simonis ab6318e538 [FIX] base: ir.model.data.name_get() respect expected behavior.
name_get() must return a value for each ids and keep order of ids.
2014-09-09 13:28:47 +02:00
Yannick Vaucher bdfa970d3d fix typo on undeclared variable xml_id 2014-09-01 16:26:55 +02:00
Martin Trigaux 80d8532370 Forward port of branch saas-5 up to rev 4895281e 2014-08-22 09:12:14 +02:00
Martin Trigaux 7bcefaf232 Forward port of branch 7.0 up to 0ab88f5 2014-08-21 17:57:57 +02:00
Martin Trigaux 0ab88f54f9 [FIX] ir_model: invalidate cache when adding new fields
When a new ir.model.field is created, add the new field in the fields_by_model (cache of custom fields). This is required as the __init__ method would not retrieve the new field if fields_by_model is already set.
Otherwise, the _columns would not contain the new fields and we could not access it without restarting the server (e.g. the installation of a module adds ir.model.fields and use it in the a view.
2014-08-21 17:24:45 +02:00
Martin Trigaux 768b3592c2 [FIX] base: wrong model change check
Comparing an id and a browse record will always fail so the exception would have always been raised when changing a model (e.g. updating a module with custom fields).
2014-08-21 14:30:10 +02:00
Martin Trigaux f138aa2608 [FIX] models: display_name and name_get mismatch
- display_name uses name_get and not the other way around:
name_get should not call _compute_display_name, _compute_display_name should call name_get.
The previous behaviour was not backward-compatible with the old api.
All the models redefining name_get would have 2 different behaviors between name_get and display_name.

- Do not set an inverse function to display_name:
In most cases, writing on display_name writes on _rec_name (if any, not mandatory).
If the display_name computation is redefined, we need to redefine as well the inverse method to avoid unexpected behaviour
This required to also modify tests in base_import as readonly fields are avoided.

- Remove search method on display_name:
For the same reason as for the first point, it could be good that searching on display_name use name_search (and not the other way around).
However doing this would be very inefficiant (need to do the search, without limit, extract the ids of the name_get result just to generate
a subdomain ('id', 'in', [...]). As in most cases it would anyway mean to search on the _rec_name it's better to directly do so.

- Changing label to avoid mismatch:
In view displaying the list of fields or when a match is made on the label of a field (e.g. when importing csv file,
matching is made on both label and technical name), the fact that display_name field has '
Calling it 'Display Name' will avoid most errors.

- remove display_name definition from website_forum_doc,ir_model:
These fields are doing the same thing as the display_name of the new api, we can remove them.
We need to keep the one for res.partner as it's a stored field.
2014-07-25 13:58:59 +02:00
Xavier Morel b2ddda47e5 [FIX] missing part of initialization in ir.model and ir.model.fields 2014-07-15 08:56:58 +02:00
Christophe Simonis f654a7719b [MERGE] forward port of branch saas-5 up to 73d39a0 2014-07-10 22:49:53 +02:00
Christophe Simonis a35aec2a0b [MERGE] forward port of branch 7.0 up to 6e96ffd 2014-07-10 22:02:01 +02:00
Xavier Morel 19c7380951 [FIX] small potential encoding issue in custom models 2014-07-10 17:34:48 +02:00
Martin Trigaux 84e9a67cdf [FIX] orm: better removal of custom m2m fields
orm: do not try to create ir.model.relation for custom m2m as self._module is either empty (for custom models), either the one of the last inheriting module (which is wrong). The field should be removed manually and should not be impacted by the uninstallation of modules. The removal of the relation table can be done when removing manually the custom field (see rev 6af3193).

ir.model: when removing a model, drop the table with the CASCADE instruction. This will remove left constraints from remaining m2m tables.
This means that dropping a table (either manually removing a custom model or uninstalling a module) will not drop the relation table for a custom m2m field. This is not ideal but better than the previous behaviour (which was to fail the DROP TABLE instruction and keep the table with a few columns and unconsistent data).
2014-07-08 15:56:24 +02:00
Martin Trigaux 6af3193d17 [FIX] ir.model.fields: better unlink
When droping a column, remove also the relation table in case of custom m2m field.
The relation table needs to be dropped otherwise an unremovable constraint to the targetted table is kept (and anyway is not needed anymore).
2014-07-08 13:55:48 +02:00
Raphael Collet cbe2dbb672 [MERGE] new v8 api by rco
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.

- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes
2014-07-06 17:05:41 +02:00
Jaydeep Barot 026e38b48f [REM] Unnecessary `size` parameters on char fields 2014-06-25 17:13:43 +02:00
Christophe Simonis 4601d85944 [MERGE] forward port of branch 7.0 up to 6fdb783 2014-06-10 11:49:14 +02:00
Martin Trigaux 426993e06d uninstall: avoid errors during uninstall
When uninstalling a module, remove the ir.model.constraint after removing the non-model records and before fields and model definition.
Without this fix, some constraint would be removed too early allowing to have broken relations and data left from removed module.
2014-06-05 12:52:11 +02:00
Christophe Simonis 38abc8a006 [MERGE] forward port of branch 7.0 up to revid b09b6a0 2014-05-20 18:57:04 +02:00
Martin Trigaux 07e4e15f4d [FIX] ir_model_fields: when adding a new custom column to a custom model, set a valid _rec_name to this model (otherwise would require a server restart to reinstanciate the model) 2014-05-15 16:25:51 +02:00
Denis Ledoux b882dd7109 [MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 5294 revid:odo@openerp.com-20140505074636-bl2y5pst4pfmpz3u
bzr revid: dle@openerp.com-20140506121627-4oyw4zl4o6azy73w
2014-05-06 14:16:27 +02:00
Denis Ledoux 93ba7cc575 [FIX] base: ir.model.fields, write, use tools.ustr instead of str so it handle if the string is already unicode
Writing special chars in the field label resulted in a traceback (write only, no problem with creation)

bzr revid: dle@openerp.com-20140428110042-qeaswuwsquy1612h
2014-04-28 13:00:42 +02:00
Christophe Simonis c7d114d9a9 [MERGE] forward port of branch saas-2 up to revid 5020 chs@openerp.com-20140312174526-a5rhh83g0fw8djuc
bzr revid: chs@openerp.com-20140312180614-8yb454s3mkjwnk2q
2014-03-12 19:06:14 +01:00
Olivier Dony 07fbbe288c [MERGE] Forward-port of 7.0 bugfixes, up to rev. 5251 revision-id: odo@openerp.com-20140304152927-havybom9x1jgdzae
bzr revid: odo@openerp.com-20140305213115-w55dqs3xra6ejmni
2014-03-05 22:31:15 +01:00
Martin Trigaux b9f72dae74 [FIX] orm: do not drop low level columns (aka 'magic columns') when deleting ir.model.fields
lp bug: https://launchpad.net/bugs/1262150 fixed

bzr revid: mat@openerp.com-20140224161918-9pe1x3jeno8t82p1
2014-02-24 17:19:18 +01:00
Denis Ledoux 5fd307b921 [FIX] ir_model: Uninstall with orphan external ids of ir.model.fields
On uninstalling, if external ids are associated to an unexisting field, we do not try to delete the field (as it doesnt exist) and we remove the orphan external ids

bzr revid: dle@openerp.com-20140221104908-7ytdg6xkxaza05o4
2014-02-21 11:49:08 +01:00
Denis Ledoux 67866db5b6 [MERGE] Forward-port of latest saas-2 bugfixes, up to rev. 5015 dle@openerp.com-20140221104908-7ytdg6xkxaza05o4
bzr revid: dle@openerp.com-20140220132700-hhc1nsu25j1ye257
bzr revid: mat@openerp.com-20140220150028-p6l0vnwa5q18uxiu
bzr revid: dle@openerp.com-20140221105500-t7jg037uusdloigl
2014-02-21 11:55:00 +01:00
Christophe Simonis 958ecb84b0 [FIX] ir.model.data: correct cache clearing
bzr revid: chs@openerp.com-20140129172949-tmwd17c2ofsqj94t
2014-01-29 18:29:49 +01:00
Antony Lesuisse 9aed30381e [FIX] ir.model.data more faithful backward compatibilty
bzr revid: al@openerp.com-20140129032053-nb5x1oll6mkpw86h
2014-01-29 04:20:53 +01:00
Antony Lesuisse 928f25a4f1 [IMP] ir.model.data clean up xmlid lookup mess
- introduce a new xmlid_ set of function with a single cache and raise_on_not_found=False
- implement backward compatible api based on the new one

bzr revid: al@openerp.com-20140129030256-pqj3eay9vf4w2m14
2014-01-29 04:02:56 +01:00
Raphael Collet 9518e6c323 [IMP] in ir_model_data.get_object(), rename parameter 'check' into 'raise_exception'
bzr revid: rco@openerp.com-20140127151726-if92mwiu3xawr8ge
2014-01-27 16:17:26 +01:00
Raphael Collet d68bb48e44 [IMP] ir.model.data: get_object() never raises an exception when check=False
bzr revid: rco@openerp.com-20140123103306-tilma2dahgfsm70t
2014-01-23 11:33:06 +01:00
Fabien Meghazi a859a53e72 [FIX] ir.model.data#_update() should honor the noupdate flag
In `init` mode, a record can still be filled with multiple record
nodes with the first node being in a data@noupdate="1" and the other
nodes without @noupdate attribute but this won't be the case anymore in
`update` mode

bzr revid: fme@openerp.com-20131216144304-2e8b9xvoks2fvlj9
2013-12-16 15:43:04 +01:00
Thibault Delavallée fea975aaa4 [IMP] ir_model: get_object: re-introduce old behavior controlled by a new argument. This allows to have a method allowing the new behavior without breaking compatibility with all addons that are based on receiving a ValueError.
bzr revid: tde@openerp.com-20131206095853-6waq2v2ajbgv02vp
2013-12-06 10:58:53 +01:00
Christophe Matthieu 8460122209 [MERGE] sync with trunk
bzr revid: chm@openerp.com-20131202150856-fzrfcoa8pmsjutau
2013-12-02 16:08:56 +01:00
Fabien Pinckaers 4a3529afdf [IMP] Performance improvement: improved cache with context, better get_object
bzr revid: fp@tinyerp.com-20131130154723-05r90b2yhwwovpx4
2013-11-30 16:47:23 +01:00
Fabien Meghazi 5f197f25c5 [IMP] raise AccessError for acl errors
bzr revid: fme@openerp.com-20131125154504-v3tfppa7mkjm5ksr
2013-11-25 16:45:04 +01:00
Christophe Simonis ab386c0f5f [MERGE] forward port of branch saas-2 up to revid 4984 chs@openerp.com-20131125151017-lmj53bxg1pfrr4a7
bzr revid: chs@openerp.com-20131125154140-cpbk4tcdml2a3b9n
2013-11-25 16:41:40 +01:00
Olivier 426a643c4f [BACKPORT] backport from saas-2 (r4976): ir.model: during garbage collection of obsolete records in _process_end, do it in anti-chronological order
bzr revid: olt@openerp.com-20131125144649-mib0vqic0nppziew
2013-11-25 15:46:49 +01:00