diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2019-01-17 09:59:23 +0000 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2019-01-17 09:59:23 +0000 |
| commit | ba39efdfc69ceaa74ea66a3d4c7fcae046cb9d19 (patch) | |
| tree | a513005dc5e2c21468212216344af97558c8a8a3 | |
| parent | 357b374a7e1be3ab8e3778aeb962bd396fe6f419 (diff) | |
[FIX] base: merge contacts linked to by an o2m field with caps
Define a field on a model as:
- o2m to res.partner
- the field's column, hence its name, has capital letters in it
(studio does that)
create two objects of that class, each one linked to a different partner with the new o2m
merge the partners
Before this commit, the object linked to the second partner, was deleted
This was because merge partner sql requests did not quote the column name
After this commit, the second object still exists
This commit is tested in v12.0 with PR #30300 only. In v10.0 it is not testable as
the model concerned is in CRM, and that no new fields in business modules can be added in stable
OPW 1925060
closes odoo/odoo#30301
| -rw-r--r-- | addons/crm/wizard/base_partner_merge.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/crm/wizard/base_partner_merge.py b/addons/crm/wizard/base_partner_merge.py index b6044efc990..82e980ba48c 100644 --- a/addons/crm/wizard/base_partner_merge.py +++ b/addons/crm/wizard/base_partner_merge.py @@ -163,14 +163,14 @@ class MergePartnerAutomatic(models.TransientModel): # unique key treated query = """ UPDATE "%(table)s" as ___tu - SET %(column)s = %%s + SET "%(column)s" = %%s WHERE - %(column)s = %%s AND + "%(column)s" = %%s AND NOT EXISTS ( SELECT 1 FROM "%(table)s" as ___tw WHERE - %(column)s = %%s AND + "%(column)s" = %%s AND ___tu.%(value)s = ___tw.%(value)s )""" % query_dic for partner in src_partners: @@ -178,7 +178,7 @@ class MergePartnerAutomatic(models.TransientModel): else: try: with mute_logger('odoo.sql_db'), self._cr.savepoint(): - query = 'UPDATE "%(table)s" SET %(column)s = %%s WHERE %(column)s IN %%s' % query_dic + query = 'UPDATE "%(table)s" SET "%(column)s" = %%s WHERE "%(column)s" IN %%s' % query_dic self._cr.execute(query, (dst_partner.id, tuple(src_partners.ids),)) # handle the recursivity with parent relation |
