forked from michel/Coworking
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
""" Event module """
|
|
|
|
from odoo import models, fields, api, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
class Event(models.Model):
|
|
""" Event model """
|
|
_name = 'coworking.event'
|
|
_description = 'Event model definition'
|
|
_order = 'id desc'
|
|
|
|
title = fields.Char(required=True)
|
|
# manager = fields.Many2one('coworker.users', 'Manager', required=True, index=True)
|
|
|
|
date_start = fields.Date(default=fields.Date.context_today, required=True)
|
|
date_end = fields.Date(required=True)
|
|
|
|
duration = fields.Float()
|
|
|
|
|
|
@api.constrains('date_end')
|
|
def _check_date_end(self):
|
|
"""Test si la modification de la date n'est pas postérieur à la date de début"""
|
|
if self.date_start > self.date_end:
|
|
raise ValidationError(_('Date most be supperior to to start date'))
|
|
|
|
#
|
|
# @api.constrains('duration')
|
|
# def _check_duration(self):
|
|
# """Calcul du temps entre date_start et date_end ne heure"""
|
|
# for event in self:
|
|
# self.date_start.hour - self.date_end-hour:
|