diff --git a/addons/calendar/__init__.py b/addons/calendar/__init__.py index 7d34c7c054a..ca9d16e5409 100644 --- a/addons/calendar/__init__.py +++ b/addons/calendar/__init__.py @@ -3,3 +3,4 @@ from . import controllers from . import models +from . import populate diff --git a/addons/calendar/populate/__init__.py b/addons/calendar/populate/__init__.py new file mode 100644 index 00000000000..8c4f64727b7 --- /dev/null +++ b/addons/calendar/populate/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import calendar_alarm +from . import data diff --git a/addons/calendar/populate/calendar_alarm.py b/addons/calendar/populate/calendar_alarm.py new file mode 100644 index 00000000000..fb6654acbcf --- /dev/null +++ b/addons/calendar/populate/calendar_alarm.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import models +from odoo.addons.calendar.populate import data +from odoo.tools import populate + + +class Alarm(models.Model): + _inherit = 'calendar.alarm' + _populate_sizes = {'small': 3, 'medium': 10, 'large': 30} + + def _populate_factories(self): + def get_name(values, counter, **kwargs): + return f"{str.capitalize(values['alarm_type'])} - {values['duration']} {values['interval']} (#{counter})." + + return [ + *((field_name, populate.iterate(*zip(*data.calendar_alarm[field_name].items()))) + for field_name in ["alarm_type", "duration", "interval"]), + ('name', populate.compute(get_name)), + ] diff --git a/addons/calendar/populate/data.py b/addons/calendar/populate/data.py new file mode 100644 index 00000000000..68d7128ca03 --- /dev/null +++ b/addons/calendar/populate/data.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +calendar_alarm = { + "alarm_type": {"email": 0.9, "notification": 0.1}, + "duration": { + 1: 0.8, + 2: 0.09, + 3: 0.11 + }, + "interval": {"hours": 0.8, "minutes": 0.1, "days": 0.1} +}