Skip to content

Commit

Permalink
[MIG] event_sale_reservation: Migration to version 17.0
Browse files Browse the repository at this point in the history
TT51924
  • Loading branch information
pilarvargas-tecnativa committed Dec 18, 2024
1 parent a5b8ea4 commit 240cdcb
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 140 deletions.
18 changes: 5 additions & 13 deletions event_sale_reservation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ exist.
.. contents::
:local:

Installation
============

To install this module, you need to:

1. Install ``web_ir_actions_act_multi`` from https://github.com/OCA/web
2. Install ``web_ir_actions_act_view_reload`` from
https://github.com/OCA/web

Configuration
=============

Expand Down Expand Up @@ -152,6 +143,7 @@ Contributors
- `Tecnativa <https://www.tecnativa.com>`__:

- Jairo Llopis
- Pilar Vargas

Maintainers
-----------
Expand All @@ -166,13 +158,13 @@ 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-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>`__:

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

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

Expand Down
6 changes: 2 additions & 4 deletions event_sale_reservation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
{
"name": "Sell event reservations",
"summary": "Allow selling event registrations before the event exists",
"version": "15.0.1.0.0",
"version": "17.0.1.0.0",
"development_status": "Beta",
"category": "Marketing",
"website": "https://github.com/OCA/event",
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["Yajo"],
"maintainers": ["pilarvargas-tecnativa"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"event_sale",
"web_ir_actions_act_multi",
"web_ir_actions_act_view_reload",
],
"data": [
"reports/sale_report_view.xml",
Expand Down
4 changes: 2 additions & 2 deletions event_sale_reservation/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ msgstr "Categoría de evento de la reserva"

#. module: event_sale_reservation
#: model:ir.model.fields.selection,name:event_sale_reservation.selection__product_template__detailed_type__event_reservation
msgid "Event Resevation"
msgstr "Reseva de Evento"
msgid "Event Reservation"
msgstr "Reserva de Evento"

#. module: event_sale_reservation
#: model:ir.model,name:event_sale_reservation.model_event_type
Expand Down
2 changes: 1 addition & 1 deletion event_sale_reservation/i18n/event_sale_reservation.pot
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ msgstr ""

#. module: event_sale_reservation
#: model:ir.model.fields.selection,name:event_sale_reservation.selection__product_template__detailed_type__event_reservation
msgid "Event Resevation"
msgid "Event Reservation"
msgstr ""

#. module: event_sale_reservation
Expand Down
2 changes: 1 addition & 1 deletion event_sale_reservation/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ msgstr "Tipo prenotazione evento"

#. module: event_sale_reservation
#: model:ir.model.fields.selection,name:event_sale_reservation.selection__product_template__detailed_type__event_reservation
msgid "Event Resevation"
msgid "Event Reservation"
msgstr "Prenotazione evento"

#. module: event_sale_reservation
Expand Down
12 changes: 0 additions & 12 deletions event_sale_reservation/migrations/15.0.1.0.0/post-migration.py

This file was deleted.

2 changes: 1 addition & 1 deletion event_sale_reservation/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ProductTemplate(models.Model):

detailed_type = fields.Selection(
selection_add=[
("event_reservation", "Event Resevation"),
("event_reservation", "Event Reservation"),
],
ondelete={"event_reservation": "set service"},
)
Expand Down
1 change: 1 addition & 0 deletions event_sale_reservation/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- [Tecnativa](https://www.tecnativa.com):
- Jairo Llopis
- Pilar Vargas
5 changes: 0 additions & 5 deletions event_sale_reservation/readme/INSTALL.md

This file was deleted.

23 changes: 9 additions & 14 deletions event_sale_reservation/reports/sale_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@ class SaleReport(models.Model):
string="Event reservation type",
)

def _query(self, with_clause="", fields=None, groupby="", from_clause=""):
if fields is None:
fields = {}
select_str = """ ,
t.event_reservation_type_id as event_reservation_type_id
"""
fields.update({"event_reservation_type_id": select_str})
groupby += ", t.event_reservation_type_id"
return super()._query(
with_clause=with_clause,
fields=fields,
groupby=groupby,
from_clause=from_clause,
)
def _select_additional_fields(self):
res = super()._select_additional_fields()
res["event_reservation_type_id"] = "t.event_reservation_type_id"
return res

def _group_by_sale(self):
res = super()._group_by_sale()
res += """, t.event_reservation_type_id"""
return res
2 changes: 1 addition & 1 deletion event_sale_reservation/reports/sale_report_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="model">sale.report</field>
<field name="inherit_id" ref="sale.view_order_product_search" />
<field name="arch" type="xml">
<filter name="Product" position="after">
<filter name="product_id" position="after">
<filter
name="groupby_event_reservation_type_id"
string="Event Reservation Type"
Expand Down
45 changes: 18 additions & 27 deletions event_sale_reservation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -377,38 +377,28 @@ <h1 class="title">Sell event reservations</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-4">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-5">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-8">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-3">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-8">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="installation">
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>To install this module, you need to:</p>
<ol class="arabic simple">
<li>Install <tt class="docutils literal">web_ir_actions_act_multi</tt> from <a class="reference external" href="https://github.com/OCA/web">https://github.com/OCA/web</a></li>
<li>Install <tt class="docutils literal">web_ir_actions_act_view_reload</tt> from
<a class="reference external" href="https://github.com/OCA/web">https://github.com/OCA/web</a></li>
</ol>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>To make use of this module, a user needs these minimal permissions:</p>
<ul class="simple">
<li>Sales / User: Own Documents Only</li>
<li>Events / User</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<p>To know how many reservations exist for a given event type:</p>
<ol class="arabic simple">
<li>Go to <em>Events &gt; Configuration &gt; Event Templates</em> and pick or create
Expand Down Expand Up @@ -468,39 +458,40 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<tt class="docutils literal">event_sale</tt> module in action.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
<p>Some addons (event_registration_multi_qty +
event_sale_registration_multi_qty) makes totals wrong because they
depend currently on count and not sum of qtys; integrating with them
would require a glue module.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">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:%20event_sale_reservation%0Aversion:%2017.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">
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Jairo Llopis</li>
<li>Pilar Vargas</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -509,7 +500,7 @@ <h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
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><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/event_sale_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
22 changes: 11 additions & 11 deletions event_sale_reservation/tests/test_event_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ def wizard_reservation_to_registration(self, order):

def wizard_step_2(self, wizard1):
"""Generate a step 2 wizard from the step 1 wizard."""
multi_action = wizard1.action_convert_to_registration()
# Ensure we first close the first wizard
self.assertEqual(multi_action["type"], "ir.actions.act_multi")
self.assertEqual(
multi_action["actions"][0]["type"], "ir.actions.act_window_close"
)
action = wizard1.action_convert_to_registration()
# Verify that the action type is open a window
self.assertEqual(action["type"], "ir.actions.act_window")
# Verify the model and context of the wizard
self.assertEqual(action["res_model"], wizard1._name)
self.assertIn("skip_event_sale_registration_multi_qty", action["context"])
self.assertFalse(action["context"]["registering_reservations"])
# Get form from 2nd chained action
action = multi_action["actions"][1]
return Form(
self.env[action["res_model"]].with_context(**action["context"]),
view=action["view_id"],
Expand All @@ -118,7 +118,7 @@ def test_wrong_product_reservation_without_type(self):
def test_event_type_open_orders(self):
"""Test the smart button that opens orders from an event type."""
self.orders.action_confirm()
groups = zip(self.event_types, self.orders, (1, 10, 100))
groups = zip(self.event_types, self.orders, (1, 10, 100), strict=True)
for ev_type, so, reservations in groups:
self.assertEqual(ev_type.seats_reservation_total, reservations)
action = ev_type.action_open_sale_orders()
Expand All @@ -127,12 +127,12 @@ def test_event_type_open_orders(self):

def test_sale_workflow(self):
# Start: orders are draft, all is pending, nothing is reserved
self.orders.invalidate_cache(["event_reservations_pending"])
self.orders.invalidate_recordset(["event_reservations_pending"])
self.assertEqual(self.orders.mapped("event_reservations_pending"), [1, 10, 100])
self.assertEqual(self.event_types.mapped("seats_reservation_total"), [0, 0, 0])
# Confirm orders: all is pending, all is reserved
self.orders.action_confirm()
self.orders.invalidate_cache(["event_reservations_pending"])
self.orders.invalidate_recordset(["event_reservations_pending"])
self.assertEqual(self.orders.mapped("event_reservations_pending"), [1, 10, 100])
self.assertEqual(
self.event_types.mapped("seats_reservation_total"), [1, 10, 100]
Expand All @@ -155,7 +155,7 @@ def test_sale_workflow(self):
wiz2_line.save()
wiz2.save().action_make_registration()
# 1st and 3rd SO are pending and reserved
self.orders.invalidate_cache(["event_reservations_pending"])
self.orders.invalidate_recordset(["event_reservations_pending"])
self.assertEqual(self.orders.mapped("event_reservations_pending"), [1, 0, 100])
self.assertEqual(
self.event_types.mapped("seats_reservation_total"), [1, 0, 100]
Expand Down
13 changes: 9 additions & 4 deletions event_sale_reservation/views/event_type_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
<record id="view_event_type_form" model="ir.ui.view">
<field name="name">Link to reservations from type</field>
<field name="model">event.type</field>
<field name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]" />
<field name="inherit_id" ref="event.view_event_type_form" />
<field name="arch" type="xml">
<div position="before">
<!-- HACK Add .oe_inline to button box to avoid broken UI with
other modules that also need to add the button box, such as
crm_event -->
<div class="oe_button_box oe_inline" name="button_box">
<div
class="oe_button_box oe_inline"
name="button_box"
groups="sales_team.group_sale_salesman"
>
<!-- Use same iconography as in contact form -->
<button
class="oe_stat_button"
Expand All @@ -29,11 +32,13 @@
<record id="view_event_type_tree" model="ir.ui.view">
<field name="name">Rerservations info from event category tree</field>
<field name="model">event.type</field>
<field name="groups_id" eval="[(4, ref('sales_team.group_sale_salesman'))]" />
<field name="inherit_id" ref="event.view_event_type_tree" />
<field name="arch" type="xml">
<tree>
<field name="seats_reservation_total" />
<field
name="seats_reservation_total"
groups="sales_team.group_sale_salesman"
/>
</tree>
</field>
</record>
Expand Down
5 changes: 3 additions & 2 deletions event_sale_reservation/views/product_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<record id="event_sale_product_template_form" model="ir.ui.view">
<field name="name">Allow products that are event registrations</field>
<field name="model">product.template</field>
<field name="groups_id" eval="[(4, ref('event.group_event_user'))]" />
<field name="inherit_id" ref="product.product_template_form_view" />
<field name="arch" type="xml">
<field name="detailed_type" position="after">
<field
name="event_reservation_type_id"
attrs="{'invisible': [('detailed_type', '!=', 'event_reservation')], 'required': [('detailed_type', '=', 'event_reservation')]}"
invisible="detailed_type != 'event_reservation'"
required="detailed_type == 'event_reservation'"
groups="event.group_event_user"
/>
</field>
</field>
Expand Down
Loading

0 comments on commit 240cdcb

Please sign in to comment.