From 640ac54867a9b2df36481ebd91e9f66427a94cf5 Mon Sep 17 00:00:00 2001 From: michel Date: Thu, 16 Nov 2017 14:53:35 +0100 Subject: [PATCH] Base relation module --- coworking_relation/__init__.py | 3 - coworking_relation/__manifest__.py | 32 -------- coworking_relation/models/coworker.py | 22 ------ coworking_relation/models/relation.py | 88 --------------------- coworking_relation/views/coworker_views.xml | 24 ------ coworking_relation/views/relation_menu.xml | 12 --- coworking_relation/views/relation_views.xml | 20 ----- 7 files changed, 201 deletions(-) delete mode 100644 coworking_relation/models/coworker.py delete mode 100644 coworking_relation/views/coworker_views.xml diff --git a/coworking_relation/__init__.py b/coworking_relation/__init__.py index cde864b..e69de29 100644 --- a/coworking_relation/__init__.py +++ b/coworking_relation/__init__.py @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from . import models diff --git a/coworking_relation/__manifest__.py b/coworking_relation/__manifest__.py index 75c49bf..e69de29 100644 --- a/coworking_relation/__manifest__.py +++ b/coworking_relation/__manifest__.py @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2017 Firstname Lastname -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -{ - 'name': 'Coworking relation', - 'summary': 'yaltik coworking module simplify your coworking gerance', - 'description': """ yaltik coworking module simplify your coworking gerance """, - 'version': '10.0.0.0.1', - 'category': 'Coworking', - 'author': 'Yaltik', - 'license': 'AGPL-3', - 'application': False, - 'installable': True, - 'data': ['security/ir.model.access.csv', - 'views/relation_views.xml', - ], - 'depends': ['coworking_coworker'] -} diff --git a/coworking_relation/models/coworker.py b/coworking_relation/models/coworker.py deleted file mode 100644 index f556f3d..0000000 --- a/coworking_relation/models/coworker.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- - -""" Coworker adaptations """ - -from odoo import models, fields, api - -class Coworker(models.Model): - """ Coworker adaptations """ - _inherit = 'coworking.coworker' - - manager_event_ids = fields.One2many('coworking.event', 'manager_id', - string='Events managed') - event_ids = fields.Many2many('coworking.event', string='Events visited') - - events_coworker_count = fields.Integer('Number of event have participe', - compute='_compute_events_coworker_count') - - @api.depends('event_ids') - def _compute_events_coworker_count(self): - """ Computes number of event coworker """ - for event in self: - event.events_coworker_count = len(event.event_ids) diff --git a/coworking_relation/models/relation.py b/coworking_relation/models/relation.py index cec3c3c..e69de29 100644 --- a/coworking_relation/models/relation.py +++ b/coworking_relation/models/relation.py @@ -1,88 +0,0 @@ -# -*- coding: utf-8 -*- - -""" relation module """ - -from datetime import datetime -from odoo import models, fields, api, _ -from odoo.exceptions import ValidationError - -class relation(models.Model): - """ relation model """ - _name = 'coworking.relation' - _description = 'relation model definition' - _rec_name = 'title' - _order = 'id asc' - - title = fields.Char(required=True) - - manager_id = fields.Many2one('coworking.coworker', 'Manager', index=True, required=True, - domain="[('coworker_type', 'in', ['staffer', 'member'])]") - date_start = fields.Datetime(default=fields.Date.context_today, required=True) - starts_this_week = fields.Integer(compute='_compute_starts_this_week', - search='_search_starts_this_week') - date_end = fields.Datetime(required=True) - - duration = fields.Float(compute='_compute_duration') - description = fields.Text() - statut = fields.Selection([('draft', 'Draft'), - ('confirmed', 'Confirmed'), - ('canceled', 'Canceled')], default='draft') - - participants_ids = fields.Many2many('coworking.coworker', string='Subscribers') - participants_count = fields.Integer('Number of participants', - compute='_compute_participants_count') - - - - @api.depends('date_start') - def _compute_starts_this_week(self): - """ Computes is relation starts this week """ - for relation in self: - date_start = fields.Datetime.from_string(relation.date_start) - week_start = date_start.isocalendar()[1] - relation.starts_this_week = (datetime.now().isocalendar()[1] == week_start) - - def _search_starts_this_week(self, operator, value): - """ Searches function for starts_this_week """ - res_ids = [] - for relation in self.search([]): - date_start = fields.Datetime.from_string(relation.date_start) - week_start = date_start.isocalendar()[1] - if datetime.now().isocalendar()[1] == week_start: - res_ids.append(relation.id) - if operator == '=': - operator = 'in'if value else 'not in' - else: - operator = 'not in'if value else 'in' - return [('id', operator, res_ids)] - - @api.depends('participants_ids') - def _compute_participants_count(self): - """ Computes number of participants """ - for relation in self: - relation.participants_count = len(relation.participants_ids) - - @api.constrains('statut', 'participants_ids') - def _check_if_confirmed(self): - """Test si participants_ids est confirmed""" - for relation in self: - if relation.participants_ids and relation.statut == 'draft': - raise models.ValidationError(_('You can have subscribed people ' - 'if relation is not confirmed yet')) - - @api.constrains('date_start', 'date_end') - def _check_dates(self): - """Test si la modification de la date de début est infnérieure à la date de fin""" - if self.date_start > self.date_end: - raise ValidationError(_('End date most be supperior to to start date')) - - @api.depends('date_start', 'date_end') - def _compute_duration(self): - for relation in self: - if relation.date_start and relation.date_end: - date_end_py = fields.Datetime.from_string(relation.date_end) - date_start_py = fields.Datetime.from_string(relation.date_start) - delta = date_end_py - date_start_py - relation.duration = delta.days * 24.0 + round(float(delta.seconds) / 3600.0) - else: - relation.duration = 0.0 diff --git a/coworking_relation/views/coworker_views.xml b/coworking_relation/views/coworker_views.xml deleted file mode 100644 index 43261e2..0000000 --- a/coworking_relation/views/coworker_views.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - Coworker Form adaptations - coworking.coworker - - - - - - - diff --git a/coworking_relation/views/relation_menu.xml b/coworking_relation/views/relation_menu.xml index 3979a09..e69de29 100644 --- a/coworking_relation/views/relation_menu.xml +++ b/coworking_relation/views/relation_menu.xml @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/coworking_relation/views/relation_views.xml b/coworking_relation/views/relation_views.xml index f47ac9c..e69de29 100644 --- a/coworking_relation/views/relation_views.xml +++ b/coworking_relation/views/relation_views.xml @@ -1,20 +0,0 @@ - - - - - - Relation Form - coworking.relation - -
- - - - - - -
-
-
- -