Skip to content

Commit

Permalink
[IMP] project_task_meeting: Remove read_group and add state to _get_p…
Browse files Browse the repository at this point in the history
…ublic_fields
  • Loading branch information
unaiberis committed Sep 5, 2024
1 parent f4387e2 commit d245235
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 40 deletions.
49 changes: 48 additions & 1 deletion project_task_meeting/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,54 @@
Project Task Meeting
====================

New shortcut from tasks to meetings.
Overview
========

The **Project Task Meeting** module enhances the Odoo project management system by linking project tasks with calendar events. It provides a seamless connection between tasks and their related meetings, allowing users to efficiently manage and track their project activities.

Features
========

- **Link Tasks to Calendar Events**:
- Adds a Many2one field in calendar events to reference the related project task.
- Displays the task's customer information in the calendar event form.

- **Task-Related Meeting Count**:
- Shows the count of related calendar events directly on the project task form and list views.

- **Navigation Shortcut**:
- Adds a button in the project task form to quickly navigate to related calendar events.

- **Enhanced Calendar Views**:

- **Calendar Event Views**:
- Adds task-related fields to calendar event forms, tree views, and search views.
- **Project Task Views**:
- Includes a field to display the number of related calendar events in task forms and tree views.

Usage
=====

After installing the module, you will see:

- **Calendar Events**:
- A new field to link each calendar event to a project task.
- The task's customer information will be displayed in the calendar event form.

- **Project Tasks**:
- A new field to display the count of related calendar events.
- A button labeled "Meetings" to open the related calendar events directly from the project task form.


Testing
=======

The module includes automated tests to ensure functionality:

- **TestProjectTaskEvent**:
- Verifies that the count of calendar events is correctly displayed.
- Checks that the navigation to calendar events from a task works as expected.


Bug Tracker
===========
Expand Down
39 changes: 3 additions & 36 deletions project_task_meeting/models/calendar_event.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# Copyright 2021 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import api, fields, models
from odoo.exceptions import AccessError
from odoo.tools.translate import _

from odoo.addons.calendar.models.calendar_event import Meeting


class CalendarEvent(models.Model):
_inherit = "calendar.event"

task_id = fields.Many2one(
string="Task",
comodel_name="project.task",
string="Task",
)

task_partner_id = fields.Many2one(
"res.partner",
comodel_name="res.partner",
string="Task Customer",
related="task_id.partner_id",
store=True,
Expand All @@ -25,34 +21,5 @@ class CalendarEvent(models.Model):
@api.model
def _get_public_fields(self):
result = super(CalendarEvent, self)._get_public_fields()
result |= {"task_id"}
result |= {"task_id", "state"}
return result

def read_group(
self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True
):
groupby = [groupby] if isinstance(groupby, str) else groupby
grouped_fields = {group_field.split(":")[0] for group_field in groupby}
private_fields = grouped_fields - self._get_public_fields()
private_fields.discard("state")
if not self.env.su and private_fields:
raise AccessError(
_(
"Grouping by %s is not allowed.",
", ".join(
[
self._fields[field_name].string
for field_name in private_fields
]
),
)
)
return super(Meeting, self).read_group(
domain,
fields,
groupby,
offset=offset,
limit=limit,
orderby=orderby,
lazy=lazy,
)
3 changes: 0 additions & 3 deletions project_task_meeting/views/calendar_event_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<field name="task_id" />
</field>
<xpath expr="//tree" position="inside">
<field name="state" optional="show" />
<field name="task_partner_id" optional="show" />
</xpath>
</field>
Expand All @@ -28,7 +27,6 @@
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="task_id" />
<field name="state" />
</field>
<filter name="availability" position="after">
<filter
Expand All @@ -37,7 +35,6 @@
domain="[]"
context="{'group_by':'task_id'}"
/>
<filter name="group-state" domain="[]" context="{'group_by':'state'}" />
</filter>
</field>
</record>
Expand Down

0 comments on commit d245235

Please sign in to comment.