Skip to content

Commit

Permalink
[15.0][IMP] resource_booking: New activity type for resource booking
Browse files Browse the repository at this point in the history
TT47152
  • Loading branch information
carolinafernandez-tecnativa committed Feb 13, 2024
1 parent 448f051 commit 034f4c6
Show file tree
Hide file tree
Showing 14 changed files with 361 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resource_booking/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Resource booking
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1b5ee844dde4d92ddebc83454b46b058b45fddf1013e7ee6d17c187c15b74318
!! source digest: sha256:8e2f6eac36cdf41491fa095fba459dcbfcb8d523de9740ae5158a171d5a9351d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
Expand Down
4 changes: 3 additions & 1 deletion resource_booking/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Resource booking",
"summary": "Manage appointments and resource booking",
"version": "15.0.1.4.2",
"version": "15.0.1.5.2",
"development_status": "Production/Stable",
"category": "Appointments",
"website": "https://github.com/OCA/calendar",
Expand All @@ -30,10 +30,12 @@
],
"data": [
"data/mail.xml",
"data/mail_data.xml",
"security/resource_booking_security.xml",
"security/ir.model.access.csv",
"templates/portal.xml",
"views/calendar_event_views.xml",
"views/mail_activity_views.xml",
"views/resource_booking_combination_views.xml",
"views/resource_booking_type_views.xml",
"views/resource_booking_views.xml",
Expand Down
10 changes: 10 additions & 0 deletions resource_booking/data/mail_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<odoo noupdate="1">
<record id="mail_activity_data_resource_booking" model="mail.activity.type">
<field name="category">resource_booking</field>
<field name="name">Resource Booking</field>
<field name="icon">fa-users</field>
<field name="sequence">11</field>
<field name="delay_count">1000</field>
</record>
</odoo>
23 changes: 23 additions & 0 deletions resource_booking/i18n/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ msgstr ""
msgid "Duration:"
msgstr ""

#. module: resource_booking
#: code:addons/resource_booking/models/mail_activity.py:0
#, python-format
msgid "Feedback: %(feedback)s"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids
Expand Down Expand Up @@ -762,6 +768,17 @@ msgstr ""
msgid "Next Activity Deadline"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id
msgid "Next Activity Resource Booking"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary
Expand Down Expand Up @@ -825,6 +842,11 @@ msgstr ""
msgid "Only one event per resource booking can exist."
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup
msgid "Open Resource Booking"
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form
msgid "Open a calendar to schedule a meeting for this booking request."
Expand Down Expand Up @@ -884,6 +906,7 @@ msgstr ""
#. module: resource_booking
#: model:ir.model,name:resource_booking.model_resource_booking
#: model:ir.module.category,name:resource_booking.category_resource_booking
#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking
msgid "Resource Booking"
msgstr ""

Expand Down
23 changes: 23 additions & 0 deletions resource_booking/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ msgstr "La duración debe ser positiva."
msgid "Duration:"
msgstr "Duración:"

#. module: resource_booking
#: code:addons/resource_booking/models/mail_activity.py:0
#, python-format
msgid "Feedback: %(feedback)s"
msgstr "Retroalimentación: %(feedback)s"

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids
Expand Down Expand Up @@ -781,6 +787,17 @@ msgstr ""
msgid "Next Activity Deadline"
msgstr "Fecha límite de siguiente actividad"

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id
msgid "Next Activity Resource Booking"
msgstr "Siguiente actividad de reserva de recursos"

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary
Expand Down Expand Up @@ -844,6 +861,11 @@ msgstr "Número de mensajes no leídos"
msgid "Only one event per resource booking can exist."
msgstr "Solo puede existir un evento por reserva de recursos."

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup
msgid "Open Resource Booking"
msgstr "Abrir una reserva de recursos"

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form
msgid "Open a calendar to schedule a meeting for this booking request."
Expand Down Expand Up @@ -910,6 +932,7 @@ msgstr "Aviso al solicitante"
#. module: resource_booking
#: model:ir.model,name:resource_booking.model_resource_booking
#: model:ir.module.category,name:resource_booking.category_resource_booking
#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking
msgid "Resource Booking"
msgstr "Reserva de recursos"

Expand Down
23 changes: 23 additions & 0 deletions resource_booking/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,12 @@ msgstr ""
msgid "Duration:"
msgstr ""

#. module: resource_booking
#: code:addons/resource_booking/models/mail_activity.py:0
#, python-format
msgid "Feedback: %(feedback)s"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids
Expand Down Expand Up @@ -756,6 +762,17 @@ msgstr ""
msgid "Next Activity Deadline"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id
msgid "Next Activity Resource Booking"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary
Expand Down Expand Up @@ -819,6 +836,11 @@ msgstr ""
msgid "Only one event per resource booking can exist."
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup
msgid "Open Resource Booking"
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form
msgid "Open a calendar to schedule a meeting for this booking request."
Expand Down Expand Up @@ -878,6 +900,7 @@ msgstr ""
#. module: resource_booking
#: model:ir.model,name:resource_booking.model_resource_booking
#: model:ir.module.category,name:resource_booking.category_resource_booking
#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking
msgid "Resource Booking"
msgstr ""

Expand Down
23 changes: 23 additions & 0 deletions resource_booking/i18n/fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,12 @@ msgstr "La durée doit être positive."
msgid "Duration:"
msgstr "Durée:"

#. module: resource_booking
#: code:addons/resource_booking/models/mail_activity.py:0
#, python-format
msgid "Feedback: %(feedback)s"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids
Expand Down Expand Up @@ -785,6 +791,17 @@ msgstr ""
msgid "Next Activity Deadline"
msgstr "Date limite de la prochaine activité"

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id
msgid "Next Activity Resource Booking"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary
Expand Down Expand Up @@ -848,6 +865,11 @@ msgstr "Nombre de messages non lus"
msgid "Only one event per resource booking can exist."
msgstr "Un seul événement par réservation de ressource peut exister."

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup
msgid "Open Resource Booking"
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form
msgid "Open a calendar to schedule a meeting for this booking request."
Expand Down Expand Up @@ -913,6 +935,7 @@ msgstr "Avis au demandeur"
#. module: resource_booking
#: model:ir.model,name:resource_booking.model_resource_booking
#: model:ir.module.category,name:resource_booking.category_resource_booking
#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking
msgid "Resource Booking"
msgstr "Réservation de ressources"

Expand Down
23 changes: 23 additions & 0 deletions resource_booking/i18n/resource_booking.pot
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,12 @@ msgstr ""
msgid "Duration:"
msgstr ""

#. module: resource_booking
#: code:addons/resource_booking/models/mail_activity.py:0
#, python-format
msgid "Feedback: %(feedback)s"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__message_follower_ids
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__message_follower_ids
Expand Down Expand Up @@ -752,6 +758,17 @@ msgstr ""
msgid "Next Activity Deadline"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_mail_activity_mixin__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_product__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_product_template__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_partner__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_res_users__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_booking_id
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_booking_id
msgid "Next Activity Resource Booking"
msgstr ""

#. module: resource_booking
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking__activity_summary
#: model:ir.model.fields,field_description:resource_booking.field_resource_booking_type__activity_summary
Expand Down Expand Up @@ -815,6 +832,11 @@ msgstr ""
msgid "Only one event per resource booking can exist."
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.mail_activity_view_form_popup
msgid "Open Resource Booking"
msgstr ""

#. module: resource_booking
#: model_terms:ir.ui.view,arch_db:resource_booking.resource_booking_form
msgid "Open a calendar to schedule a meeting for this booking request."
Expand Down Expand Up @@ -874,6 +896,7 @@ msgstr ""
#. module: resource_booking
#: model:ir.model,name:resource_booking.model_resource_booking
#: model:ir.module.category,name:resource_booking.category_resource_booking
#: model:mail.activity.type,name:resource_booking.mail_activity_data_resource_booking
msgid "Resource Booking"
msgstr ""

Expand Down
1 change: 1 addition & 0 deletions resource_booking/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import resource_booking_type_combination_rel
from . import resource_calendar
from . import resource_resource
from . import mail_activity
58 changes: 58 additions & 0 deletions resource_booking/models/mail_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import _, fields, models, tools
from odoo.tools import is_html_empty


class MailActivityType(models.Model):
_inherit = "mail.activity.type"

category = fields.Selection(
selection_add=[("resource_booking", "Resource booking")]
)


class MailActivity(models.Model):
_inherit = "mail.activity"

booking_id = fields.Many2one(
"resource.booking", string="Resource booking", ondelete="cascade"
)

def action_create_resource_booking(self):
self.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id(
"resource_booking.resource_booking_action"
)
if self.booking_id:
action["domain"] = [("id", "=", self.booking_id.id)]
else:
action["context"] = {
"default_activity_type_id": self.activity_type_id.id,
"default_res_id": self.env.context.get("default_res_id"),
"default_res_model": self.env.context.get("default_res_model"),
"default_name": self.summary or self.res_name,
"default_description": self.note
if not is_html_empty(self.note)
else "",
"default_booking_activity_ids": [(6, 0, self.ids)],
}
return action

def _action_done(self, feedback=False, attachment_ids=False):
bookings = self.mapped("booking_id")
messages, activities = super(MailActivity, self)._action_done(
feedback=feedback, attachment_ids=attachment_ids
)
if feedback:
for booking in bookings:
description = booking.description
description = "%s<br />%s" % (
description if not tools.is_html_empty(description) else "",
_("Feedback: %(feedback)s", feedback=tools.plaintext2html(feedback))
if feedback
else "",
)
booking.write({"description": description})
return messages, activities
Loading

0 comments on commit 034f4c6

Please sign in to comment.