Add Event

This commit is contained in:
michel 2017-11-10 15:03:12 +01:00
parent 4a3d2da366
commit 32687eafcd
5 changed files with 74 additions and 2 deletions

View File

@ -25,6 +25,7 @@
'license': 'AGPL-3',
'application': False,
'installable': True,
'data': ['views/coworking_menu.xml', 'views/coworker_views.xml', 'security/ir.model.access.csv'],
'data': ['views/coworking_menu.xml', 'views/coworker_views.xml',
'security/ir.model.access.csv', 'views/event_menu.xml', 'views/event_views.xml'],
'depends': ['base']
}

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""dd"""
from . import coworker
from . import event

34
models/event.py Normal file
View File

@ -0,0 +1,34 @@
# -*- 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:

11
views/event_menu.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Action to open Coworkers list -->
<act_window id="event_action" name="Event"
res_model="coworking.event" view_mode="form" />
<!-- Menu item to open Coworkers list -->
<menuitem id="event_menu" name="Event" action="event_action" />
</odoo>

25
views/event_views.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Form -->
<record id="view_form_event" model="ir.ui.view">
<field name="name">Event Form</field>
<field name="model">coworking.event</field>
<field name="arch" type="xml">
<form string="event">
<sheet>
<group name="group_top">
<group name="group_left">
<field name="title" />
<!-- <field name="manager" /> -->
<field name="date_start" />
<field name="date_end" />
<field name="duration" />
</group>
</group>
</sheet>
</form>
</field>
</record>
</odoo>