[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: deeb769c0d579c51ab42b072ccc1c013d79fcea4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user