diff options
| author | Xavier Morel <xmo@odoo.com> | 2021-03-03 12:21:58 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2021-03-16 14:16:12 +0000 |
| commit | 221ea6079b2beeb66c4cfa48b237791e1b380c5e (patch) | |
| tree | a3bef39c1f938782a24c7e2e45ec8d26ace6fb0a /odoo/tools/debugger.py | |
| parent | 681e709b239c2456c71d1c16bb40de055dfb927c (diff) | |
[FIX] base_automation: mis-ordered computation of stored fields
Client issue: when updating the company of a contact, the Display Name
keeps using the previous company's name, so given Bob in company A, if
Bob is moved to company B the form's title remains "A, Bob" instead of
becoming "B, Bob". More annoying, if Bob is moved back to A the name
becomes "B, Bob".
On res.partner, `display_name` is a stored computed field which
depends on `commercial_company_name` (via `name_get` -> `_get_name` ->
`_get_contact_name`). This is an other stored computed name, which
depends on `commercial_partner_id`, which is yet another stored
computed name, which depends on the `parent_id`.
The dependencies are meh but usually resolve fine, the issue occurs
when a base.automation rule is created with a non-empty
domain (including an empty literal list, which was the case here):
when the first field of the sequence is computed, base.automation's
`_compute_field_value` is called. This calls `_filter_pre`,
which (because `filter_pre_domain` is non-empty) calls `search` on the
model.
This would normally be innocuous as `search` will only flush the
fields used in the search, however for `res.partner` the default
`_order` is... `display_name`. Meaning we flush that computation,
forcing the computation of `commercial_company_name`, but since
`commercial_partner_id` is being computed we reuse its old value (or
something), which is not re-recomputed after the
`commercial_partner_id` computation ends.
So rather than resolve a full search involving an order, filter the
records in-place.
OPW-2427264
closes odoo/odoo#67953
X-original-commit: e09a44db6a04cd37ad6f28b859f927970ac93fc5
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'odoo/tools/debugger.py')
0 files changed, 0 insertions, 0 deletions
