-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[15.0][IMP] resource_booking: New activity type for resource booking
TT47152
- Loading branch information
1 parent
448f051
commit ab104e7
Showing
15 changed files
with
320 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.