Skip to content

Commit

Permalink
[MIG] sale_crm_event_reservation: Migration to version 17.0
Browse files Browse the repository at this point in the history
TT51941
  • Loading branch information
pilarvargas-tecnativa committed Jan 14, 2025
1 parent e8e61e6 commit 0650502
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 66 deletions.
17 changes: 10 additions & 7 deletions sale_crm_event_reservation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Create event quotations from opportunities
!! source digest: sha256:08a4d72558ab1cb7796630463d64cce3503eaa98283529e2132d7cd067fbc2b2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
:alt: Mature
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
Expand Down Expand Up @@ -122,13 +122,16 @@ 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.

.. |maintainer-Yajo| image:: https://github.com/Yajo.png?size=40px
:target: https://github.com/Yajo
:alt: Yajo
.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px
:target: https://github.com/chienandalu
:alt: chienandalu
.. |maintainer-pilarvargas-tecnativa| image:: https://github.com/pilarvargas-tecnativa.png?size=40px
:target: https://github.com/pilarvargas-tecnativa
:alt: pilarvargas-tecnativa

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Yajo|
|maintainer-chienandalu| |maintainer-pilarvargas-tecnativa|

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

Expand Down
6 changes: 3 additions & 3 deletions sale_crm_event_reservation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
{
"name": "Create event quotations from opportunities",
"summary": "Combine event reservations, opportunities and quotations",
"version": "15.0.1.0.1",
"development_status": "Beta",
"version": "17.0.1.0.0",
"development_status": "Mature",
"category": "Marketing",
"website": "https://github.com/OCA/event",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["Yajo"],
"maintainers": ["chienandalu", "pilarvargas-tecnativa"],
"license": "AGPL-3",
"application": False,
"installable": True,
Expand Down
6 changes: 3 additions & 3 deletions sale_crm_event_reservation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Create event quotations from opportunities</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:08a4d72558ab1cb7796630463d64cce3503eaa98283529e2132d7cd067fbc2b2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.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/sale_crm_event_reservation"><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-sale_crm_event_reservation"><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="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.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/sale_crm_event_reservation"><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-sale_crm_event_reservation"><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>This module extends the functionality of <em>crm_event</em>,
<em>event_sale_reservation</em> and <em>sale_crm</em> to support fast generation of
event quotations from opportunities and to allow you to sell events like
Expand Down Expand Up @@ -468,8 +468,8 @@ <h2><a class="toc-backref" href="#toc-entry-8">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>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/Yajo"><img alt="Yajo" src="https://github.com/Yajo.png?size=40px" /></a></p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/chienandalu"><img alt="chienandalu" src="https://github.com/chienandalu.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/pilarvargas-tecnativa"><img alt="pilarvargas-tecnativa" src="https://github.com/pilarvargas-tecnativa.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/event/tree/17.0/sale_crm_event_reservation">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>
Expand Down
4 changes: 2 additions & 2 deletions sale_crm_event_reservation/tests/test_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_register(self):
self.assertEqual(
so.order_line.event_ticket_id, self.event_1.event_ticket_ids[0]
)
self.assertTrue(so.order_line.event_ok)
self.assertTrue(so.order_line.product_id.detailed_type == "event")
self.assertEqual(
so.order_line.product_uom_qty,
3,
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_reserve(self):
self.assertEqual(so.order_line.product_id, self.product_reservation_1)
self.assertFalse(so.order_line.event_id)
self.assertFalse(so.order_line.event_ticket_id)
self.assertFalse(so.order_line.event_ok)
self.assertFalse(so.order_line.product_id.detailed_type == "event")
self.assertEqual(
so.order_line.product_uom_qty,
3,
Expand Down
4 changes: 2 additions & 2 deletions sale_crm_event_reservation/views/crm_lead_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<field name="name">Add button to create event quotation</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="sale_crm.crm_case_form_view_oppor" />
<field name="groups_id" eval="[(4, ref('event.group_event_user'))]" />
<field name="arch" type="xml">
<button name="action_set_won_rainbowman" position="before">
<button
string="New Event Quotation"
name="%(crm_lead_event_sale_wizard_action)d"
type="action"
class="oe_highlight"
attrs="{'invisible': ['|', '|', '|', ('partner_id', '=', False), ('event_type_id', '=', False), ('seats_wanted', '=', 0), '&amp;', ('probability', '=', 0), ('active', '=', False)]}"
invisible="not partner_id or not event_type_id or seats_wanted == 0 or (not probability and not active)"
context="{'default_opportunity_id': id, 'default_event_type_id': event_type_id, 'default_seats_wanted': seats_wanted}"
groups="event.group_event_user"
/>
</button>
</field>
Expand Down
84 changes: 46 additions & 38 deletions sale_crm_event_reservation/wizards/crm_lead_event_sale_wizard.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2021 Tecnativa - Jairo Llopis
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo import api, fields, models
from odoo.tests.common import Form


Expand Down Expand Up @@ -41,60 +41,68 @@ class CRMLeadEventSale(models.TransientModel):
("event_reservation_type_id", "=", event_type_id),
]
""",
context="""
{
"default_event_reservation_ok": True,
"default_event_reservation_type_id": event_type_id,
}
""",
index=True,
ondelete="cascade",
string="Product",
)
allowed_event_ids = fields.Many2many(
comodel_name="event.event",
compute="_compute_allowed_event_ids",
readonly=True,
)
event_id = fields.Many2one(
comodel_name="event.event",
domain="""
[
("event_type_id", "=", event_type_id),
("date_end", ">=", datetime.date.today().strftime("%Y-%m-%d")),
("is_finished", "!=", True),
"|",
("seats_limited", "=", False),
("seats_available", ">=", seats_wanted),
]
""",
context="""
{
"default_event_type_id": event_type_id,
}
""",
domain="[('id', 'in', allowed_event_ids)]",
index=True,
ondelete="cascade",
string="Event",
)
allowed_event_ticket_ids = fields.Many2many(
comodel_name="event.event.ticket",
compute="_compute_allowed_event_ticket_ids",
readonly=True,
)
event_ticket_id = fields.Many2one(
comodel_name="event.event.ticket",
domain="""
[
("event_id", "=", event_id),
"|",
("end_sale_datetime", "=", False),
("end_sale_datetime", ">=", datetime.date.today().strftime("%Y-%m-%d")),
"|",
("seats_limited", "=", False),
("seats_available", ">=", seats_wanted),
]
""",
context="""
{
"default_event_id": event_id,
}
""",
domain="[('id', 'in', allowed_event_ticket_ids)]",
index=True,
ondelete="cascade",
string="Ticket",
)

@api.depends("mode")
def _compute_allowed_event_ids(self):
for record in self:
events = self.env["event.event"].search(
[
("event_type_id", "=", record.event_type_id.id),
("date_end", ">=", fields.Date.today()),
("is_finished", "=", False),
]
)
record.allowed_event_ids = events.filtered(
lambda event: not event.seats_limited
or event.seats_available >= self.seats_wanted
)

@api.depends("event_id")
def _compute_allowed_event_ticket_ids(self):
for record in self:
record.allowed_event_ticket_ids = []
if record.event_id:
tickets = self.env["event.event.ticket"].search(
[
("event_id", "=", record.event_id.id),
"|",
("end_sale_datetime", "=", False),
("end_sale_datetime", ">=", fields.Date.today()),
]
)
record.allowed_event_ticket_ids = tickets.filtered(
lambda ticket: not ticket.seats_limited
or ticket.seats_available >= self.seats_wanted
)

def action_generate(self):
"""Create an event reservation sales order."""
# Creating a sale order properly involves lots of onchanges, so here it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,28 @@
<field name="seats_wanted" />
<field name="mode" widget="radio" />
</group>
<group
name="register"
attrs="{'invisible': [('mode', '!=', 'register')]}"
>
<group name="register" invisible="mode != 'register'">
<field name="allowed_event_ids" invisible="1" />
<field name="allowed_event_ticket_ids" invisible="1" />
<field
name="event_id"
attrs="{'required': [('mode', '=', 'register')]}"
required="mode == 'register'"
context="{'default_event_type_id': event_type_id}"
/>
<field
name="event_ticket_id"
attrs="{'required': [('mode', '=', 'register')]}"
required="mode == 'register'"
context="{'default_event_id': event_id,}"
/>
</group>
<group
name="reserve"
attrs="{'invisible': [('mode', '!=', 'reserve')]}"
>
<group name="reserve" invisible="mode != 'reserve'">
<field
name="product_id"
attrs="{'required': [('mode', '=', 'reserve')]}"
required="mode == 'reserve'"
context="{
'default_event_reservation_ok': True,
'default_event_reservation_type_id': event_type_id,
}"
/>
</group>
</sheet>
Expand Down

0 comments on commit 0650502

Please sign in to comment.