res_config_settings.py 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
from odoo import models, fields, api, _
from odoo.exceptions import UserError

class MaintenanceResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'


    time_simple_alert_maintenance = fields.Float('Tiempo de atención simple')
    time_medium_alert_maintenance = fields.Float('Tiempo de atención media')
    time_extreme_alert_maintenance = fields.Float('Tiempo de atención máxima')
    color_simple_alert_maintenance = fields.Integer("Color para atención simple",default=3)
    color_medium_alert_maintenance = fields.Integer("Color para atención media",default=2)
    color_extreme_alert_maintenance = fields.Integer("Color para atención máxima",default=9)


    def set_values(self):
        super(MaintenanceResConfigSettings, self).set_values()
        self.env['ir.config_parameter'].set_param('helpdesk_maintenance.time_simple_alert_maintenance', self.time_simple_alert_maintenance)
        self.env['ir.config_parameter'].set_param('helpdesk_maintenance.time_medium_alert_maintenance', self.time_medium_alert_maintenance)
        self.env['ir.config_parameter'].set_param('helpdesk_maintenance.time_extreme_alert_maintenance', self.time_extreme_alert_maintenance)
        self.env['ir.config_parameter'].set_param('helpdesk_maintenance.color_simple_alert_maintenance', self.color_simple_alert_maintenance)
        self.env['ir.config_parameter'].set_param('helpdesk_maintenance.color_medium_alert_maintenance', self.color_medium_alert_maintenance)
        self.env['ir.config_parameter'].set_param('helpdesk_maintenance.color_extreme_alert_maintenance', self.color_extreme_alert_maintenance)

    @api.model
    def get_values(self):
        res = super(MaintenanceResConfigSettings, self).get_values()
        params = self.env['ir.config_parameter'].sudo()
        res.update(time_simple_alert_maintenance=params.get_param('helpdesk_maintenance.time_simple_alert_maintenance'))
        res.update(time_medium_alert_maintenance=params.get_param('helpdesk_maintenance.time_medium_alert_maintenance'))
        res.update(time_extreme_alert_maintenance=params.get_param('helpdesk_maintenance.time_extreme_alert_maintenance'))
        res.update(color_simple_alert_maintenance=params.get_param('helpdesk_maintenance.color_simple_alert_maintenance'))
        res.update(color_medium_alert_maintenance=params.get_param('helpdesk_maintenance.color_medium_alert_maintenance'))
        res.update(color_extreme_alert_maintenance=params.get_param('helpdesk_maintenance.color_extreme_alert_maintenance'))
        return res