Skip to content
Snippets Groups Projects
Commit 65edd6c5 authored by jvm-odoo's avatar jvm-odoo
Browse files

[FIX] base: fix merge partner wizard


In the contacts app, you can select 2 partners and merge them.

Before this commit:

    - If a partner was added by a SQL query and not directly on Odoo,
      the create_date will be empty. This causes a crash because the
      merge wizard try to sort the partners by date

After this commit:

    - If a partner do not have a create_date, it will be considered
      as 01/01/1970. The merge wizard will sort the partners by IDs too.

OPW-2091925

closes odoo/odoo#39523

X-original-commit: deeb769c
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent fb853753
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import functools
import itertools
import logging
import psycopg2
import datetime
from odoo import api, fields, models
from odoo import SUPERUSER_ID, _
......@@ -409,7 +410,7 @@ class MergePartnerAutomatic(models.TransientModel):
:param partner_ids : list of partner ids to sort
"""
return self.env['res.partner'].browse(partner_ids).sorted(
key=lambda p: (p.active, (p.create_date or '')),
key=lambda p: (p.active, (p.create_date or datetime.datetime(1970, 1, 1))),
reverse=True,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment