-
-
Notifications
You must be signed in to change notification settings - Fork 198
[18.0][MIG]Add forbid_duplicates on event_type #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| # Copyright 2022 Tecnativa - Luis D. Lafaurie | ||
| # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
|
||
| from odoo import api, fields, models | ||
| from odoo import _, api, fields, models | ||
| from odoo.exceptions import ValidationError | ||
|
|
||
|
|
||
|
|
@@ -13,6 +13,9 @@ class EventEvent(models.Model): | |
| forbid_duplicates = fields.Boolean( | ||
| help="Check this to disallow duplicate attendees in this event's " | ||
| "registrations", | ||
| compute="_compute_forbid_duplicates", | ||
| store=True, | ||
| readonly=False, | ||
| ) | ||
|
|
||
| @api.constrains("forbid_duplicates", "registration_ids") | ||
|
|
@@ -22,6 +25,15 @@ def _check_forbid_duplicates(self): | |
| "forbid_duplicates" | ||
| ).registration_ids._check_forbid_duplicates() | ||
|
|
||
| @api.depends("event_type_id") | ||
| def _compute_forbid_duplicates(self): | ||
| """Update event configuration from its event type. Depends are set only | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a slight behavior change, as previously changing the type doesn't touch the field, but I think it can be acceptable. |
||
| on event_type_id itself, not its sub fields. Purpose is to emulate an | ||
| onchange: if event type is changed, update event configuration. Changing | ||
| event type content itself should not trigger this method.""" | ||
| for event in self: | ||
| event.forbid_duplicates = event.event_type_id.forbid_duplicates | ||
|
|
||
|
|
||
| class EventRegistration(models.Model): | ||
| _inherit = "event.registration" | ||
|
|
@@ -34,7 +46,7 @@ def _check_forbid_duplicates(self): | |
| if dupes: | ||
| # pylint: disable=W8120 | ||
| raise ValidationError( | ||
| self.env._("Duplicated partners found in event {0}: {1}.").format( | ||
| _("Duplicated partners found in event {0}: {1}.").format( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't change this. |
||
| event_reg.event_id.display_name, | ||
| ", ".join( | ||
| partner_id.display_name | ||
|
|
@@ -51,3 +63,11 @@ def _duplicate_search_domain(self): | |
| ("attendee_partner_id", "=", self.attendee_partner_id.id), | ||
| ("attendee_partner_id", "!=", False), | ||
| ] | ||
|
|
||
|
|
||
| class EventType(models.Model): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put this is a new file. |
||
| _inherit = "event.type" | ||
| forbid_duplicates = fields.Boolean( | ||
| help="Check this to disallow duplicate attendees in this event's " | ||
| "registrations" | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| <field name="priority" eval="99" /> | ||
| <field name="inherit_id" ref="event.view_event_form" /> | ||
| <field name="arch" type="xml"> | ||
| <xpath expr="//field[@name='create_partner']" position="after"> | ||
| <xpath expr="//field[@name='badge_image']" position="after"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why changing this. |
||
| <field name="forbid_duplicates" /> | ||
| </xpath> | ||
| </field> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <odoo> | ||
| <record id="view_event_type_form" model="ir.ui.view"> | ||
| <field name="name">Add option to avoid duplicates</field> | ||
| <field name="model">event.type</field> | ||
| <!-- Make sure this view is loaded after event_sale's one, as it replaces full page --> | ||
| <field name="priority" eval="99" /> | ||
| <field name="inherit_id" ref="event.view_event_type_form" /> | ||
| <field name="arch" type="xml"> | ||
| <xpath expr="//field[@name='tag_ids']" position="after"> | ||
| <field name="forbid_duplicates" /> | ||
| </xpath> | ||
| </field> | ||
| </record> | ||
| </odoo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add the redundant dependency