-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] event_registration_partner_unique: avoid constraint on merge
When a user merges two contacts an error will raise if there are event with a unique partner constraint when both partner were atendees. With these changes, we let the user get rid of those duplicated attendees. TT45921
- Loading branch information
1 parent
80a92d9
commit 92172be
Showing
8 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from . import models | ||
from . import wizards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import base_partner_merge |
21 changes: 21 additions & 0 deletions
21
event_registration_partner_unique/wizards/base_partner_merge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2023 Tecnativa - David Vidal | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from odoo import fields, models | ||
|
||
|
||
class BasePartnerMergeAutomaticWizard(models.TransientModel): | ||
_inherit = "base.partner.merge.automatic.wizard" | ||
|
||
merge_duplicated_registrations = fields.Boolean( | ||
help="If the merged partners were linked to registrations in an event that had " | ||
"unique attendees flag we'll take only the oldest one", | ||
) | ||
|
||
def action_merge(self): | ||
"""Inject context so we can deal with duplicates when merging""" | ||
if self.merge_duplicated_registrations: | ||
return super( | ||
BasePartnerMergeAutomaticWizard, | ||
self.with_context(merge_registration_partner_unique=True), | ||
).action_merge() | ||
return super().action_merge() | ||
12 changes: 12 additions & 0 deletions
12
event_registration_partner_unique/wizards/base_partner_merge_views.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="base_partner_merge_automatic_wizard_form" model="ir.ui.view"> | ||
<field name="inherit_id" ref="base.base_partner_merge_automatic_wizard_form" /> | ||
<field name='model'>base.partner.merge.automatic.wizard</field> | ||
<field name='arch' type='xml'> | ||
<field name="dst_partner_id" position="after"> | ||
<field name="merge_duplicated_registrations" /> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |