Skip to content

Commit 6259d39

Browse files
[MIG] calendar_event_type_color: Migration to 18.0
1 parent 2d79857 commit 6259d39

9 files changed

Lines changed: 43 additions & 8 deletions

File tree

calendar_event_type_color/README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ Contributors
6868
- Iván Todorovich <ivan.todorovich@camptocamp.com>
6969
- Maksym Yankin <maksym.yankin@camptocamp.com>
7070

71+
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__
72+
73+
- Bhavesh Heliconia
74+
7175
Other credits
7276
-------------
7377

calendar_event_type_color/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Calendar Event Type Color",
66
"summary": "Colorize calendar view depending on event type color",
7-
"version": "16.0.1.0.0",
7+
"version": "18.0.1.0.0",
88
"author": "Camptocamp, Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/calendar",
1010
"maintainers": ["yankinmax"],

calendar_event_type_color/models/calendar_event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ class CalendarEvent(models.Model):
1212
@api.depends("categ_ids")
1313
def _compute_color(self):
1414
for event in self:
15-
event.color = fields.first(event.categ_ids).color
15+
first_tag = fields.first(event.categ_ids)
16+
event.color = first_tag.color if first_tag else 0

calendar_event_type_color/readme/CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
> - Iván Todorovich \<<ivan.todorovich@camptocamp.com>\>
44
> - Maksym Yankin \<<maksym.yankin@camptocamp.com>\>
5+
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
6+
- Bhavesh Heliconia

calendar_event_type_color/static/description/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>

calendar_event_type_color/static/src/views/attendee_calendar/attendee_calendar_model.esm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import {AttendeeCalendarModel} from "@calendar/views/attendee_calendar/attendee_calendar_model";
44
import {patch} from "@web/core/utils/patch";
55

6-
patch(AttendeeCalendarModel.prototype, "calendar_event_type_color", {
6+
patch(AttendeeCalendarModel.prototype, {
77
/**
88
* @override
99
* Set color to the event type color
1010
*/
1111
async updateAttendeeData(data) {
12-
const res = await this._super(...arguments);
12+
const res = await super.updateAttendeeData(...arguments);
1313
for (const event of Object.values(data.records)) {
1414
const eventData = event.rawRecord;
1515
event.colorIndex = eventData.color;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_calendar_event
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from odoo.tests.common import TransactionCase
2+
3+
4+
class TestCalendarEventColor(TransactionCase):
5+
def test_color_computation_with_tag(self):
6+
tag = self.env["calendar.event.type"].create(
7+
{
8+
"name": "Blue",
9+
"color": 5,
10+
}
11+
)
12+
event = self.env["calendar.event"].create(
13+
{
14+
"name": "Event with Tag",
15+
"categ_ids": [(6, 0, [tag.id])],
16+
}
17+
)
18+
event._compute_color()
19+
self.assertEqual(event.color, 5)
20+
21+
def test_color_computation_without_tag(self):
22+
event = self.env["calendar.event"].create(
23+
{
24+
"name": "Event without Tag",
25+
}
26+
)
27+
event._compute_color()
28+
self.assertEqual(event.color, 0)

calendar_event_type_color/views/calendar_event_type_views.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
<field name="inherit_id" ref="calendar.view_calendar_event_type_tree" />
66
<field name="priority">90</field>
77
<field name="arch" type="xml">
8-
<tree position="inside">
8+
<list position="inside">
99
<field name="color" widget="color_picker" optional="show" />
10-
</tree>
10+
</list>
1111
</field>
1212
</record>
1313
<record id="calendar_event_type_action" model="ir.actions.act_window">
1414
<field name="name">Calendar Event Type</field>
1515
<field name="res_model">calendar.event.type</field>
16-
<field name="view_mode">tree</field>
16+
<field name="view_mode">list</field>
1717
</record>
1818
<menuitem
1919
id="calendar_management_menu"

0 commit comments

Comments
 (0)