[IMP] calendar: populate calendar alarms

Task-2728093
See odoo/enterprise#23707

closes odoo/odoo#83265

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Florian Charlier
2022-01-26 08:48:52 +00:00
parent 722f0f9b65
commit de1cba13e3
4 changed files with 39 additions and 0 deletions
+1
View File
@@ -3,3 +3,4 @@
from . import controllers
from . import models
from . import populate
+5
View File
@@ -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
@@ -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)),
]
+12
View File
@@ -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}
}