Skip to content

Commit

Permalink
[MIG] calendar_event_link_base: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cvinh committed Jan 22, 2024
1 parent 8056606 commit 1e50dff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion calendar_event_link_base/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"summary": """
This module add an abstract model that provide an action to link
any model to calendar events""",
"version": "12.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/calendar",
Expand Down
18 changes: 10 additions & 8 deletions calendar_event_link_base/models/calendar_event_link_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ class CalendarEventLinkMixin(models.AbstractModel):

event_count = fields.Integer(compute="_compute_event_count")

@api.multi
def _compute_event_count(self):
for x in self.env["calendar.event"].read_group(
[("res_model", "=", self._name), ("res_id", "in", self.ids)],
["id"],
["res_id"],
):
self.browse(x["res_id"]).update({"event_count": x["res_id_count"]})
mapped_data = self.env["calendar.event"].read_group(
[("res_model", "=", self._name), ("res_id", "in", self.ids)],
["id"],
["res_id"],
)
if mapped_data:
for x in mapped_data:
self.browse(x["res_id"]).update({"event_count": x["res_id_count"]})
else:
self.event_count = 0

@api.multi
def action_show_events(self):
self.ensure_one()
context = {
Expand Down

0 comments on commit 1e50dff

Please sign in to comment.