Skip to content

Commit

Permalink
[IMP] base: allow configure if src partners are deleted or archived a…
Browse files Browse the repository at this point in the history
…fter merge

Currently, the source partners used in mergings are deleted, this change
allows to configure if the partners are going to be deleted or archived.
  • Loading branch information
fernandahf committed Jan 9, 2024
1 parent f95540b commit 7564a18
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions odoo/addons/base/wizard/base_partner_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from odoo import api, fields, models, Command
from odoo import SUPERUSER_ID, _
from odoo.exceptions import ValidationError, UserError
from odoo.tools import mute_logger
from odoo.tools import mute_logger, str2bool

_logger = logging.getLogger('odoo.addons.base.partner.merge')

Expand Down Expand Up @@ -320,8 +320,12 @@ def _merge(self, partner_ids, dst_partner=None, extra_checks=True):

self._log_merge_operation(src_partners, dst_partner)

# delete source partner, since they are merged
src_partners.unlink()
# check parameter to see if it should delete or archive
delete_src_partners = str2bool(self.env["ir.config_parameter"].sudo().get_param("base.delete_merged_src_partners", True))
if delete_src_partners:
src_partners.unlink()
else:
src_partners.write({src_partners._active_name: False})

def _log_merge_operation(self, src_partners, dst_partner):
_logger.info('(uid = %s) merged the partners %r with %s', self._uid, src_partners.ids, dst_partner.id)
Expand Down

0 comments on commit 7564a18

Please sign in to comment.