Skip to content

Commit

Permalink
[MIG] partner_event: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Feb 3, 2025
1 parent c4895bd commit cffee4f
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 15 deletions.
15 changes: 9 additions & 6 deletions partner_event/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Link partner to events
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a3b195a7a102a169ba55ad5650ad4eb36b876331adb852831693071e29cbb94f
!! source digest: sha256:6be5d9ae845bdda4af3d8a73313c28535066b72429f4a3d3ac666aed3c9e0b16
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand All @@ -17,13 +17,13 @@ Link partner to events
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github
:target: https://github.com/OCA/event/tree/17.0/partner_event
:target: https://github.com/OCA/event/tree/18.0/partner_event
:alt: OCA/event
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/event-17-0/event-17-0-partner_event
:target: https://translation.odoo-community.org/projects/event-18-0/event-18-0-partner_event
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -70,7 +70,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/event/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/event/issues/new?body=module:%20partner_event%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/event/issues/new?body=module:%20partner_event%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -102,6 +102,9 @@ Contributors
- Javier Iniesta

- Anil Kesariya
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

Maintainers
-----------
Expand All @@ -116,6 +119,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/event <https://github.com/OCA/event/tree/17.0/partner_event>`_ project on GitHub.
This module is part of the `OCA/event <https://github.com/OCA/event/tree/18.0/partner_event>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion partner_event/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{
"name": "Link partner to events",
"version": "17.0.1.0.1",
"version": "18.0.1.0.0",
"category": "Marketing",
"author": "Tecnativa," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/event",
Expand Down
4 changes: 1 addition & 3 deletions partner_event/models/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def _update_attendee_partner_id(self, vals):
Event = self.env["event.event"]
# Look for a partner with that email
email = vals.get("email").replace("%", "").replace("_", "\\_")
attendee_partner = Partner.search(
[("email", "=ilike", email)], limit=1, order="id"
)
attendee_partner = Partner.search([("email", "=ilike", email)], limit=1)
event = Event.browse()
if vals.get("event_id"):
event = Event.browse(vals["event_id"])
Expand Down
2 changes: 2 additions & 0 deletions partner_event/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
- [Antiun](https://antiun.com/):
- Javier Iniesta
- Anil Kesariya
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
12 changes: 8 additions & 4 deletions partner_event/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Link partner to events</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a3b195a7a102a169ba55ad5650ad4eb36b876331adb852831693071e29cbb94f
!! source digest: sha256:6be5d9ae845bdda4af3d8a73313c28535066b72429f4a3d3ac666aed3c9e0b16
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/event/tree/17.0/partner_event"><img alt="OCA/event" src="https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/event-17-0/event-17-0-partner_event"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/event&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/event/tree/18.0/partner_event"><img alt="OCA/event" src="https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/event-18-0/event-18-0-partner_event"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/event&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module links partners with the events they are registered through a
smart button.</p>
<p>It also includes:</p>
Expand Down Expand Up @@ -415,7 +415,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/event/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/event/issues/new?body=module:%20partner_event%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/event/issues/new?body=module:%20partner_event%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -446,6 +446,10 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
</ul>
</li>
<li>Anil Kesariya</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a><ul>
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -457,7 +461,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/event/tree/17.0/partner_event">OCA/event</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/event/tree/18.0/partner_event">OCA/event</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
62 changes: 62 additions & 0 deletions partner_event/tests/test_event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,65 @@ def test_delete_registered_partner(self):
partner3 = self.env["res.partner"].create({"name": "unregistered partner"})
partner3.unlink()
self.assertFalse(partner3.exists())

def test_update_attendee_partner_id(self):
# Case: No existing partner with the email
vals = {
"email": "[email protected]",
"event_id": self.event_0.id,
"name": "New Name",
}
self.registration_01._update_attendee_partner_id(vals)
self.assertTrue(vals["attendee_partner_id"]) # Ensure partner was created
new_partner = self.env["res.partner"].browse(vals["attendee_partner_id"])
self.assertEqual(new_partner.email, "[email protected]")
self.assertEqual(new_partner.name, "New Name")

vals = {"email": "[email protected]", "event_id": self.event_0.id}
self.registration_01._update_attendee_partner_id(vals)
self.assertEqual(vals["attendee_partner_id"], self.partner_01.id)

vals = {"email": "[email protected]"}
registration_with_context = self.env["event.registration"].with_context(
partner_event_merging=True
)
registration_with_context._update_attendee_partner_id(vals)
self.assertNotIn("attendee_partner_id", vals)

def test_prepare_partner(self):
vals = {"name": "Test Name", "email": "[email protected]", "phone": "123456"}
expected_result = {
"name": "Test Name",
"email": "[email protected]",
"phone": "123456",
}
result = self.registration_01._prepare_partner(vals)
self.assertEqual(result, expected_result)

vals = {"email": "[email protected]"}
result = self.registration_01._prepare_partner(vals)
self.assertEqual(result["name"], "[email protected]")

def test_onchange_partner_id(self):
# Create a registration with an attendee partner
registration = self.env["event.registration"].create(
{
"email": "[email protected]",
"event_id": self.event_0.id,
"attendee_partner_id": self.partner_01.id,
}
)
registration_with_context = registration.with_context(
get_attendee_partner_address=self.partner_01
)
registration_with_context._onchange_partner_id()
self.assertEqual(registration_with_context.partner_id, self.partner_01)

def test_action_merge(self):
# Apply the context for partner merging
wizard_with_context = self.env[
"base.partner.merge.automatic.wizard"
].with_context(partner_event_merging=True)
wizard = wizard_with_context.create({})

wizard.action_merge()
2 changes: 1 addition & 1 deletion partner_event/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<record id="act_partner_registration" model="ir.actions.act_window">
<field name="res_model">event.registration</field>
<field name="name">Registrations</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="view_mode">list,form,calendar,graph</field>
<field name="domain">[("attendee_partner_id", "child_of", active_ids)]</field>
<field
name="context"
Expand Down

0 comments on commit cffee4f

Please sign in to comment.