8000 [FIX] account: allow merging partners with audit trail · odoo-dev/odoo@c3f7e50 · GitHub
[go: up one dir, main page]

Skip to content

Commit c3f7e50

Browse files
committed
[FIX] account: allow merging partners with audit trail
When the audit trail feature was enabled, it was impossible to merge the partners. Since we don't lose any information, we allow that action specifically. Because it should never be allowed in non controlled settings, we use a python token so that the context key cannot be used with RPC calls. closes odoo#174938 X-original-commit: f43b0fb Signed-off-by: Wala Gauthier (gawa) <gawa@odoo.com> Signed-off-by: William André (wan) <wan@odoo.com>
1 parent 628af8b commit c3f7e50

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

addons/account/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from . import ir_ui_menu
4040
from . import mail_message
4141
from . import mail_tracking_value
42+
from . import merge_partner_automatic
4243
from . import res_currency
4344
from . import account_report
4445
from . import onboarding_onboarding_step

addons/account/models/mail_message.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from odoo.exceptions import UserError
77
from odoo.osv.expression import OR
88

9+
bypass_token = object()
910
DOMAINS = {
1011
'account.move': lambda operator, value: [('company_id.check_account_audit_trail', operator, value)],
1112
'account.account': lambda operator, value: [('company_id.check_account_audit_trail', operator, value)],
@@ -152,6 +153,8 @@ def _search_audit_log_related_record_id(self, model, operator, value):
152153

153154
@api.ondelete(at_uninstall=True)
154155
def _except_audit_log(self):
156+
if self.env.context.get('bypass_audit') is bypass_token:
157+
return
155158
for message in self:
156159
if message.account_audit_log_activated and not (
157160
message.account_audit_log_move_id
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from odoo import models
2+
from .mail_message import bypass_token
3+
4+
5+
class MergePartnerAutomatic(models.TransientModel):
6+
_inherit = 'base.partner.merge.automatic.wizard'
7+
8+
def _update_reference_fields(self, src_partners, dst_partner):
9+
return super(MergePartnerAutomatic, self.with_context(bypass_audit=bypass_token))._update_reference_fields(src_partners, dst_partner)

0 commit comments

Comments
 (0)
0