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 Jan 15, 2024
1 parent 448f051 commit ab104e7
Show file tree
Hide file tree
Showing 15 changed files with 320 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
9 changes: 9 additions & 0 deletions resource_booking/data/mail_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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>
</record>
</odoo>
18 changes: 18 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 @@ -884,6 +901,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
18 changes: 18 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 @@ -910,6 +927,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
18 changes: 18 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 @@ -878,6 +895,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
18 changes: 18 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 @@ -913,6 +930,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
18 changes: 18 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 @@ -874,6 +891,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
2 changes: 2 additions & 0 deletions resource_booking/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
from . import resource_booking_type_combination_rel
from . import resource_calendar
from . import resource_resource
from . import mail_activity
from . import mail_activity_mixin
53 changes: 53 additions & 0 deletions resource_booking/models/mail_activity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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"
)
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_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
22 changes: 22 additions & 0 deletions resource_booking/models/mail_activity_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 Tecnativa - Carolina Fernandez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class MailActivityMixin(models.AbstractModel):
_inherit = "mail.activity.mixin"

activity_booking_id = fields.Many2one(
"resource.booking",
string="Next Activity Resource Booking",
compute="_compute_activity_booking_id",
groups="base.group_user",
)

@api.depends("activity_ids.booking_id")
def _compute_activity_booking_id(self):
"""This computes the resource booking of the next activity.
It evaluates to false if there is no such event."""
for record in self:
record.activity_booking_id = record.activity_ids[:1].booking_id

Check warning on line 22 in resource_booking/models/mail_activity_mixin.py

View check run for this annotation

Codecov / codecov/patch

resource_booking/models/mail_activity_mixin.py#L22

Added line #L22 was not covered by tests
1 change: 1 addition & 0 deletions resource_booking/models/resource_booking.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class ResourceBooking(models.Model):
required=True,
tracking=True,
)
activity_ids = fields.One2many("mail.activity", "booking_id", string="Activities")

@api.depends("partner_ids")
def _compute_partner_id(self):
Expand Down
3 changes: 2 additions & 1 deletion resource_booking/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -366,7 +367,7 @@ <h1 class="title">Resource booking</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1b5ee844dde4d92ddebc83454b46b058b45fddf1013e7ee6d17c187c15b74318
!! source digest: sha256:8e2f6eac36cdf41491fa095fba459dcbfcb8d523de9740ae5158a171d5a9351d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/calendar/tree/15.0/resource_booking"><img alt="OCA/calendar" src="https://img.shields.io/badge/github-OCA%2Fcalendar-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/calendar-15-0/calendar-15-0-resource_booking"><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/calendar&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds a new app to allow you to book resource combinations in given
Expand Down
Loading

0 comments on commit ab104e7

Please sign in to comment.