forked from michel/Coworking
Compare commits
158 Commits
V1
...
V5_unit_te
Author | SHA1 | Date | |
---|---|---|---|
a600f20bbb | |||
95dc6a23b6 | |||
22134ca9ee | |||
0e5b176930 | |||
34efb13093 | |||
007af79930 | |||
176e5ce696 | |||
817665d782 | |||
161dcdaafe | |||
9e40808da7 | |||
32f8dd52ea | |||
97192b2a3c | |||
8ffd023640 | |||
c6c518ff68 | |||
6685e4e369 | |||
58d6dec996 | |||
525dda9f04 | |||
611dc6f5f4 | |||
3cf2ff0ebc | |||
521cccce69 | |||
e21d5b92f4 | |||
d266986445 | |||
a9d9429b04 | |||
b00b0c96a4 | |||
c2e8df0081 | |||
7c17942736 | |||
30bd4eb2d3 | |||
49526c558b | |||
8287e674aa | |||
48a5facf34 | |||
32f86786af | |||
498774c8a7 | |||
aaca3b3db1 | |||
1c46c0f04e | |||
3330976fdd | |||
1c80800633 | |||
31306e5b57 | |||
60d4824375 | |||
2a1e846304 | |||
2411fdb93c | |||
affa853857 | |||
2ce2c58a82 | |||
6c8e3a9ccf | |||
7d52c03561 | |||
83c684ff7d | |||
cb9bf0e328 | |||
0ff1cc2066 | |||
a0d00c22e0 | |||
7438312291 | |||
0b6b5053c7 | |||
e306960bb0 | |||
ce23b7e78e | |||
7111308501 | |||
7e9a754b44 | |||
6a1e2cdd28 | |||
8c81f0eee6 | |||
3f7865bba3 | |||
949ecb41ee | |||
44042e87a8 | |||
ebb8b20e14 | |||
824dbc7cda | |||
61274df36d | |||
2eea737322 | |||
c40deb8fe7 | |||
3421890717 | |||
96d3cb418e | |||
3c68ea83d5 | |||
cad38216de | |||
83ad2867ee | |||
00ecfada76 | |||
5e0cd006d5 | |||
8a62f38159 | |||
16758eec6d | |||
78ff3e754f | |||
679fc4ce4f | |||
aa0d4d36d0 | |||
ccb82a0c72 | |||
a74caf97ca | |||
0a67eabbd3 | |||
f3e9c630de | |||
c2f395a2e6 | |||
34b0f1f385 | |||
db6e19bba9 | |||
76be13ae5d | |||
f7ef7f73cc | |||
a679dcea4d | |||
0aba5d585e | |||
48255707e4 | |||
5c2b3b0b2c | |||
e37774fff6 | |||
e048a9e9f0 | |||
704ac03ca9 | |||
f0d5897b15 | |||
eeffe7b5ba | |||
912d4fdfc6 | |||
3ec1260069 | |||
640ac54867 | |||
d652ceaccd | |||
5b7ac167cb | |||
20ade01c56 | |||
e99374796b | |||
6601bed446 | |||
c8f398e913 | |||
288462c096 | |||
7ac77e3762 | |||
f3ddaaf2d8 | |||
e0ce682b3f | |||
7cc3482546 | |||
f0e9dbab4d | |||
e26e6fd1c7 | |||
0585672d52 | |||
ffd1399e67 | |||
545749ac50 | |||
67c875e987 | |||
797bef0aee | |||
877632aab8 | |||
6bb35e925d | |||
f3ca56cf61 | |||
aeb16e6923 | |||
eaf4999a22 | |||
663219440c | |||
547221525b | |||
8800cab3ab | |||
168f28d0c9 | |||
c47575ce45 | |||
1c81289236 | |||
e9d9c1bb9d | |||
539cedf663 | |||
d303d69b96 | |||
39bb404f99 | |||
0ae67777a6 | |||
5d650a71cb | |||
05f69c4aec | |||
d183b8b344 | |||
4c687fb6a5 | |||
8f80bfed16 | |||
32687eafcd | |||
4a3d2da366 | |||
f286e714b9 | |||
2abdd3584f | |||
a5ddde9994 | |||
98ee48126d | |||
ebd17586e2 | |||
3f595c957a | |||
831020620f | |||
666274b883 | |||
a78bec621f | |||
650664245d | |||
7b33b11789 | |||
25fadfdb56 | |||
f9b2d63d79 | |||
9eddf23d7e | |||
66809f1d25 | |||
60530a4c3c | |||
1c2175b51b | |||
561aa7a49d | |||
a197f65db5 | |||
eca14eb74d |
1
coworking_app/__init__.py
Normal file
1
coworking_app/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
32
coworking_app/__manifest__.py
Normal file
32
coworking_app/__manifest__.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017 Firstname Lastname <firstname.lastname@company.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
'name': 'Coworking whole Application',
|
||||
'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': True,
|
||||
'installable': True,
|
||||
'data': [],
|
||||
'demo': ['data/coworking_app_demo.xml'],
|
||||
|
||||
'depends': ['coworking_coworker', 'coworking_event']
|
||||
}
|
146
coworking_app/data/coworking_app_demo.xml
Normal file
146
coworking_app/data/coworking_app_demo.xml
Normal file
@ -0,0 +1,146 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<odoo>
|
||||
<!-- Coworker -->
|
||||
<record id="name_hs" model="res.partner">
|
||||
<field name="name">Homer Simpson</field>
|
||||
<field name="contact_date">2017-11-27</field>
|
||||
<field name="is_coworker">True</field>
|
||||
<field name="coworker_type">worker</field>
|
||||
<field name="street">320 Rue de la pioche</field>
|
||||
<field name="zip">88000</field>
|
||||
<field name="city">Flousin</field>
|
||||
<field name="country_id" ref="base.fr" />
|
||||
</record>
|
||||
<record id="name_jr" model="res.partner">
|
||||
<field name="name">Joe Robert</field>
|
||||
<field name="contact_date">2017-11-29</field>
|
||||
<field name="is_coworker">True</field>
|
||||
<field name="coworker_type">staffer</field>
|
||||
<field name="street">26 Rue de la roche</field>
|
||||
<field name="zip">38054</field>
|
||||
<field name="city">Chambéry</field>
|
||||
<field name="country_id" ref="base.fr" />
|
||||
</record>
|
||||
<record id="name_ra" model="res.partner">
|
||||
<field name="name">Rob Altros</field>
|
||||
<field name="contact_date">2017-11-29</field>
|
||||
<field name="is_coworker">True</field>
|
||||
<field name="coworker_type">member</field>
|
||||
<field name="street">874 avenue de la source</field>
|
||||
<field name="zip">38054</field>
|
||||
<field name="city">Grosland</field>
|
||||
<field name="country_id" ref="base.fr" />
|
||||
</record>
|
||||
<record id="name_so" model="res.partner">
|
||||
<field name="name">Sophie Lira</field>
|
||||
<field name="contact_date">2017-11-29</field>
|
||||
<field name="is_coworker">True</field>
|
||||
<field name="coworker_type">volunteer</field>
|
||||
<field name="street">2 avenue chirolin</field>
|
||||
<field name="zip">38054</field>
|
||||
<field name="city">Grosland</field>
|
||||
<field name="country_id" ref="base.fr" />
|
||||
</record>
|
||||
<record id="name_cb" model="res.partner">
|
||||
<field name="name">Camille Bréa</field>
|
||||
<field name="contact_date">2017-11-29</field>
|
||||
<field name="is_coworker">True</field>
|
||||
<field name="coworker_type">visitor</field>
|
||||
<field name="street">6 Impase des monts</field>
|
||||
<field name="zip">00254</field>
|
||||
<field name="city">Grosland</field>
|
||||
<field name="country_id" ref="base.fr" />
|
||||
</record>
|
||||
|
||||
<!-- Events -->
|
||||
<record id="event_1" model="coworking.event">
|
||||
<field name="title">Evenement</field>
|
||||
<field name="manager_id" ref="name_hs" />
|
||||
<field name="date_start">2017-11-29</field>
|
||||
<field name="date_end">2017-12-02</field>
|
||||
<field name="description">Test de demo création d'event</field>
|
||||
<field name="participants_ids" eval="[(4, ref('name_jr'), False)]"/>
|
||||
<field name="statut">confirmed</field>
|
||||
</record>
|
||||
<record id="event_2" model="coworking.event">
|
||||
<field name="title">Formation</field>
|
||||
<field name="manager_id" ref="name_cb" />
|
||||
<field name="date_start">2017-11-29</field>
|
||||
<field name="date_end">2017-11-30</field>
|
||||
<field name="description">Test de demo création d'event</field>
|
||||
<field name="participants_ids" eval="[(4, ref('name_hs'), False)]"/>
|
||||
<field name="statut">confirmed</field>
|
||||
</record>
|
||||
<record id="event_3" model="coworking.event">
|
||||
<field name="title">Cuisine</field>
|
||||
<field name="manager_id" ref="name_so" />
|
||||
<field name="date_start">2017-11-29</field>
|
||||
<field name="date_end">2017-11-30</field>
|
||||
<field name="description">Test de demo création d'event</field>
|
||||
<field name="participants_ids" eval="[(4, ref('name_ra'), False)]"/>
|
||||
<field name="statut">confirmed</field>
|
||||
</record>
|
||||
<record id="event_4" model="coworking.event">
|
||||
<field name="title">Méditation</field>
|
||||
<field name="manager_id" ref="name_so" />
|
||||
<field name="date_start">2017-12-05</field>
|
||||
<field name="date_end">2017-12-10</field>
|
||||
<field name="description">Test de demo création d'event</field>
|
||||
<field name="participants_ids" eval="[(6, 0, [ref('name_hs'),
|
||||
ref('name_ra'), ref('name_cb')])]" />
|
||||
<field name="statut">confirmed</field>
|
||||
</record>
|
||||
|
||||
<!-- relations -->
|
||||
<record id="rela_1" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_so" />
|
||||
<field name="coworker2" ref="name_hs" />
|
||||
<field name="relation">Soeur</field>
|
||||
</record>
|
||||
<record id="rela_2" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_hs" />
|
||||
<field name="coworker2" ref="name_so" />
|
||||
<field name="relation">Frére</field>
|
||||
</record>
|
||||
<record id="rela_3" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_cb" />
|
||||
<field name="coworker2" ref="name_ra" />
|
||||
<field name="relation">Père</field>
|
||||
</record>
|
||||
<record id="rela_4" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_ra" />
|
||||
<field name="coworker2" ref="name_cb" />
|
||||
<field name="relation">Mère</field>
|
||||
</record>
|
||||
<record id="rela_5" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_hs" />
|
||||
<field name="coworker2" ref="name_ra" />
|
||||
<field name="relation">Donuts</field>
|
||||
</record>
|
||||
<record id="rela_6" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_ra" />
|
||||
<field name="coworker2" ref="name_hs" />
|
||||
<field name="relation">Psy</field>
|
||||
</record>
|
||||
<record id="rela_7" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_jr" />
|
||||
<field name="coworker2" ref="name_hs" />
|
||||
<field name="relation">Ami</field>
|
||||
</record>
|
||||
<record id="rela_8" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_so" />
|
||||
<field name="coworker2" ref="name_jr" />
|
||||
<field name="relation">Ami</field>
|
||||
</record>
|
||||
<record id="rela_9" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_jr" />
|
||||
<field name="coworker2" ref="name_ra" />
|
||||
<field name="relation">Cousin</field>
|
||||
</record>
|
||||
<record id="rela_10" model="coworking.relation">
|
||||
<field name="coworker1" ref="name_ra" />
|
||||
<field name="coworker2" ref="name_jr" />
|
||||
<field name="relation">Cousine</field>
|
||||
</record>
|
||||
</odoo>
|
1
coworking_base/__init__.py
Normal file
1
coworking_base/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
@ -16,15 +16,14 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
'name': 'Coworking',
|
||||
'name': 'Coworking base',
|
||||
'summary': 'yaltik coworking module simplify your coworking gerance',
|
||||
'description': """ yaltik coworking module simplify your coworking gerance """,
|
||||
'version': '10.0.0.0.1',
|
||||
'category': 'Useless',
|
||||
'category': 'Coworking',
|
||||
'author': 'Yaltik',
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'data': ['views/coworking_menu.xml', 'views/coworker_views.xml'],
|
||||
'depends': ['base']
|
||||
'depends': ['contacts']
|
||||
}
|
31
coworking_coworker/__manifest__.py
Normal file
31
coworking_coworker/__manifest__.py
Normal file
@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017 Firstname Lastname <firstname.lastname@company.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
'name': 'Coworking coworker',
|
||||
'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': ['views/res_partner_views.xml'],
|
||||
|
||||
'depends': ['coworking_base']
|
||||
}
|
2
coworking_coworker/models/__init__.py
Normal file
2
coworking_coworker/models/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import res_partner
|
69
coworking_coworker/models/coworker.py
Normal file
69
coworking_coworker/models/coworker.py
Normal file
@ -0,0 +1,69 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworker module """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class Coworker(models.Model):
|
||||
""" Coworker model """
|
||||
_name = 'coworking.coworker'
|
||||
_description = 'Coworker model definition'
|
||||
_order = 'id desc'
|
||||
contact_date = fields.Date(default=fields.Date.context_today)
|
||||
|
||||
full_name = fields.Char(compute='_compute_full_name', store=True, index=True)
|
||||
firstname = fields.Char('First name', required=True)
|
||||
|
||||
coworker_type = fields.Selection([('staffer', 'Staffer'),
|
||||
('worker', 'Worker'), ('member', 'Member'),
|
||||
('volunteer', 'Volunteer'),
|
||||
('visitor', 'Visitor')])
|
||||
company_name = fields.Char('Company')
|
||||
job = fields.Char()
|
||||
|
||||
#Adress fields
|
||||
street = fields.Char()
|
||||
contact_zip = fields.Char()
|
||||
city = fields.Char()
|
||||
full_contact_adress = fields.Char(compute='_compute_full_contact_adress')
|
||||
|
||||
phone_number = fields.Char()
|
||||
gsm = fields.Char('GSM')
|
||||
email = fields.Char()
|
||||
url = fields.Char('URL')
|
||||
note = fields.Text()
|
||||
|
||||
#Images fields
|
||||
contact_image = fields.Binary()
|
||||
|
||||
is_done = fields.Boolean('Done?')
|
||||
is_active = fields.Boolean('Active?', default=True)
|
||||
|
||||
@api.depends('name', 'firstname')
|
||||
def _compute_full_name(self):
|
||||
"""Concaténation du nom et du prénom"""
|
||||
for coworker in self:
|
||||
coworker.full_name = u'{} {}'.format(coworker.name, coworker.firstname)
|
||||
|
||||
@api.constrains('contact_date')
|
||||
def _check_contact_date(self):
|
||||
"""Test si la modification de la date n'est pas superieur à la date du jour"""
|
||||
if self.contact_date > fields.Date.context_today(self):
|
||||
raise ValidationError(_('Date most be equal of inferior to to day'))
|
||||
|
||||
@api.constrains('company_name', 'job')
|
||||
def _check_company_name(self):
|
||||
for coworker in self:
|
||||
"""Contrainte python sur company_name et job,
|
||||
si il y a une raison sociale le champ job est à remplir
|
||||
"""
|
||||
if coworker.company_name and not coworker.job:
|
||||
raise ValidationError(_('You must enter job and compagny both'))
|
||||
|
||||
@api.depends('street', 'contact_zip', 'city')
|
||||
def _compute_full_contact_adress(self):
|
||||
"""Concatènation de l'adresse si les chanps street, contact-zip et city sont renseignés"""
|
||||
for coworker in self:
|
||||
coworker.full_contact_adress = u'{} {} {}'.format \
|
||||
(coworker.street or u'', coworker.contact_zip or u'', coworker.city or u'').strip()
|
62
coworking_coworker/models/res_partner.py
Normal file
62
coworking_coworker/models/res_partner.py
Normal file
@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworker module """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class ResPartner(models.Model):
|
||||
""" Coworker model """
|
||||
_inherit = 'res.partner'
|
||||
|
||||
is_coworker = fields.Boolean('Coworker', default=False)
|
||||
company_ids = fields.One2many(
|
||||
string="Company",
|
||||
comodel_name="res.partner",
|
||||
inverse_name="parent_id",
|
||||
)
|
||||
|
||||
url = fields.Char('URL')
|
||||
|
||||
contact_date = fields.Date(default=fields.Date.context_today)
|
||||
|
||||
coworker_type = fields.Selection([('staffer', 'Staffer'),
|
||||
('worker', 'Worker'), ('member', 'Member'),
|
||||
('volunteer', 'Volunteer'),
|
||||
('visitor', 'Visitor')])
|
||||
|
||||
full_contact_adress = fields.Char(compute='_compute_full_contact_adress')
|
||||
|
||||
@api.depends('street', 'zip', 'city')
|
||||
def _compute_full_contact_adress(self):
|
||||
"""Concatènation de l'adresse si les chanps street, czip et city sont renseignés"""
|
||||
for coworker in self:
|
||||
coworker.full_contact_adress = u'{} {} {}'.format \
|
||||
(coworker.street or u'', coworker.zip or u'', coworker.city or u'').strip()
|
||||
|
||||
@api.constrains('contact_date')
|
||||
def _check_contact_date(self):
|
||||
"""Test si la modification de la date n'est pas superieur à la date du jour"""
|
||||
if self.contact_date > fields.Date.context_today(self):
|
||||
raise ValidationError(_('Date most be equal of inferior to to day'))
|
||||
|
||||
@staticmethod
|
||||
def _manage_coworker_type(vals):
|
||||
""" Ensures that coworker_type is not defined when is_coworker is False """
|
||||
if 'is_coworker' in vals:
|
||||
if not vals['is_coworker']:
|
||||
vals.update({'coworker_type': False})
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
""" Ensures that coworker_type is not defined when is_coworker is False """
|
||||
vals = ResPartner._manage_coworker_type(vals)
|
||||
return super(ResPartner, self).create(vals)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
""" Ensures that coworker_type is not defined when is_coworker is False """
|
||||
vals = ResPartner._manage_coworker_type(vals)
|
||||
super(ResPartner, self).write(vals)
|
||||
return True
|
3
coworking_coworker/security/ir.model.access.csv
Normal file
3
coworking_coworker/security/ir.model.access.csv
Normal file
@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
acess_coworker_group_user,Access COWORKER Member User,model_coworking_coworker,base.group_user,1,1,1,0
|
||||
acess_coworker_group_manager,Access COWORKER Member Manager,model_coworking_coworker,base.group_partner_manager,1,1,1,1
|
|
3
coworking_coworker/tests/__init__.py
Normal file
3
coworking_coworker/tests/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_coworking_coworker
|
60
coworking_coworker/tests/test_coworking_coworker.py
Normal file
60
coworking_coworker/tests/test_coworking_coworker.py
Normal file
@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworking cowoker testing module """
|
||||
|
||||
from datetime import date
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
class TestCoworkingCoworker(TransactionCase):
|
||||
""" Coworking cowoker testing """
|
||||
|
||||
def setUp(self, *args, **kwargs):
|
||||
""" Bootstrap testing """
|
||||
super(TestCoworkingCoworker, self).setUp(*args, **kwargs)
|
||||
data = {'name': 'Homer Simpson', 'is_coworker': True}
|
||||
self.homer = self.env['res.partner'].create(data)
|
||||
|
||||
def test_contact_date(self):
|
||||
""" Test contact date : default to today and validity """
|
||||
contact_date = fields.Date.from_string(self.homer.contact_date)
|
||||
self.assertEqual(contact_date, date.today())
|
||||
|
||||
marge = self.env['res.partner'].create({'name': 'Marge Simpson',
|
||||
'contact_date': '2017-01-01'})
|
||||
self.assertEqual(marge.contact_date, '2017-01-01')
|
||||
|
||||
with self.assertRaises(ValidationError) as err:
|
||||
data = {'name': 'Bart Simpson', 'contact_date': '2999-01-01'}
|
||||
self.env['res.partner'].create(data)
|
||||
self.assertIn('equal of inferior to', unicode(err.exception))
|
||||
|
||||
def test_full_address(self):
|
||||
"""Test full address"""
|
||||
self.homer.write({'street': False, 'zip': False, 'city': False})
|
||||
self.assertEqual(self.homer.full_contact_adress, u'')
|
||||
|
||||
self.homer.write({'street': False, 'zip': False, 'city': u'Springfield'})
|
||||
self.assertEqual(self.homer.full_contact_adress, u'Springfield')
|
||||
|
||||
self.homer.write({'street': False, 'zip': u'5555', 'city': u'Springfield'})
|
||||
self.assertEqual(self.homer.full_contact_adress, u'5555 Springfield')
|
||||
|
||||
self.homer.write({'street': u'42 Liberty Street', 'zip': u'5555', 'city': u'Springfield'})
|
||||
self.assertEqual(self.homer.full_contact_adress, u'42 Liberty Street 5555 Springfield')
|
||||
|
||||
self.homer.write({'street': u'42 Liberty Street', 'zip': False, 'city': u'Springfield'})
|
||||
self.assertEqual(self.homer.full_contact_adress, u'42 Liberty Street Springfield')
|
||||
|
||||
|
||||
def test_manage_coworker_type(self):
|
||||
""" Test that non-coworker have not coworker_type fixed """
|
||||
self.homer.write({'is_coworker': False})
|
||||
self.assertFalse(self.homer.coworker_type)
|
||||
|
||||
self.homer.write({'coworker_type': 'visitor'})
|
||||
self.assertEqual(self.homer.coworker_type, 'visitor')
|
||||
|
||||
self.homer.write({'is_coworker': False, 'coworker_type': 'staffer'})
|
||||
self.assertFalse(self.homer.coworker_type)
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<odoo>
|
||||
<!-- Form -->
|
||||
<record id="view_form_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Form</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
@ -10,62 +10,70 @@
|
||||
<sheet>
|
||||
<group name="group_top">
|
||||
<group name="group_left">
|
||||
<field name="contact_image" widget="image" class="oe_avatar"/>
|
||||
<field name="contact_date" />
|
||||
<field name="full_name" />
|
||||
<field name="name" />
|
||||
<field name="firstname" />
|
||||
<field name="coworker_type" />
|
||||
<field name="company_name" />
|
||||
<field name="job"
|
||||
attrs="{'invisible': [('company_name', '=', False)], 'required': [('company_name', '!=', False)]}" />
|
||||
<field name="job" />
|
||||
</group>
|
||||
<group name="group_right">
|
||||
<field name="street" />
|
||||
<field name="contact_zip" />
|
||||
<field name="city" />
|
||||
<field name="full_contact_adress" />
|
||||
<field name="gsm" />
|
||||
<field name="phone_number" />
|
||||
<field name="email" />
|
||||
<field name="url" />
|
||||
<field name="is_done" />
|
||||
<field name="is_active" readonly="1" />
|
||||
</group>
|
||||
<field name="note" />
|
||||
<field name="is_done" />
|
||||
<field name="is_active" readonly="1" />
|
||||
</group>
|
||||
</group>
|
||||
<groupe>
|
||||
<notebook>
|
||||
<page string="Note" name="note">
|
||||
<field name="note" />
|
||||
</page>
|
||||
</notebook>
|
||||
</groupe>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Tree -->
|
||||
<record id="view_tree_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Tree</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="name asc, firstname asc">
|
||||
<field name="name" />
|
||||
<field name="firstname" />
|
||||
<field name="full_name" />
|
||||
<field name="company_name" />
|
||||
<field name="full_contact_adress" />
|
||||
<field name="gsm" />
|
||||
<field name="email" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Search -->
|
||||
<record id="view_search_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Search</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="contact_date" />
|
||||
<field name="name" />
|
||||
<field name="firstname" />
|
||||
<field name="full_name" />
|
||||
<field name="company_name" />
|
||||
<field name="gsm" />
|
||||
<field name="email" />
|
||||
|
||||
<filter name="individual" string="Individual"
|
||||
domain="[('company_name','=',False)]" />
|
||||
|
||||
<filter name="in_compagny" string="in_compagny"
|
||||
domain="[('company_name','!=',False)]" />
|
||||
|
||||
@ -90,5 +98,45 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Kanban -->
|
||||
<record id="view_kanban_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Kanban</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban>
|
||||
<field name="contact_image" />
|
||||
<field name="full_name" />
|
||||
<field name="full_contact_adress" />
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_vignette oe_semantic_html_override">
|
||||
<div class="o_kanban_image">
|
||||
<img t-if="record.contact_image.raw_value"
|
||||
t-att-src="'data:image/png;base64,'+ record.contact_image.raw_value"/>
|
||||
<t t-if="!record.contact_image.raw_value">
|
||||
</t>
|
||||
</div>
|
||||
<div>
|
||||
<field name="full_name" />
|
||||
<field name="full_contact_adress" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Calendar -->
|
||||
<record id="view_calendar_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Calendar</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar date_start="contact_date"
|
||||
display="First contact : [name]" >
|
||||
<field name="name" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
15
coworking_coworker/views/coworking_menu.xml
Normal file
15
coworking_coworker/views/coworking_menu.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Action to open Coworkers list -->
|
||||
<act_window id="coworker_action" name="Coworkers"
|
||||
res_model="coworking.coworker" view_mode="tree,form,kanban,calendar" />
|
||||
|
||||
<!-- Menu item to open Coworkers list -->
|
||||
<menuitem id="coworker_menu" name="Coworkers" />
|
||||
<menuitem id="coworker_list" name="Coworkers" action="coworker_action"
|
||||
parent="coworker_menu" sequence="1" />
|
||||
|
||||
|
||||
</odoo>
|
119
coworking_coworker/views/res_partner_views.xml
Normal file
119
coworking_coworker/views/res_partner_views.xml
Normal file
@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
<!-- Form -->
|
||||
<record id="view_form_res_partner" model="ir.ui.view">
|
||||
<field name="name">>res.partner.form.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref ="base.view_partner_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="type" position="after">
|
||||
<field name="is_coworker" />
|
||||
<field name="coworker_type"
|
||||
attrs="{'invisible': [('is_coworker','=', False)]}" />
|
||||
<field name="contact_date" />
|
||||
</field>
|
||||
<field name="email" position="after">
|
||||
<field name="url" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree -->
|
||||
<record id="view_tree_res_partner" model="ir.ui.view">
|
||||
<field name="name">res.partner.tree.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref ="base.view_partner_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="phone" position="before">
|
||||
<field name="company_name" />
|
||||
<field name="full_contact_adress" />
|
||||
</field>
|
||||
<field name="phone" position="replace">
|
||||
<field name="mobile" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search -->
|
||||
<record id="view_search_res_partner" model="ir.ui.view">
|
||||
<field name="name">res.partner.search.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref ="base.view_res_partner_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<search position="inside">
|
||||
<filter name="group_coworker_type" string="Group coworker type"
|
||||
context="{'group_by': 'coworker_type'}" />
|
||||
<filter name="group_title" string="by title"
|
||||
context="{'group_by': 'title'}" />
|
||||
<filter name="group_city" string="City"
|
||||
context="{'group_by': 'city'}" />
|
||||
<filter name="is_coworker" string="Coworker"
|
||||
domain="[('is_coworker','=',True)]" />
|
||||
<filter name="group_month" string="Month"
|
||||
context="{'group_by': 'contact_date:month'}" />
|
||||
<filter name="group_year" string="Year"
|
||||
context="{'group_by': 'contact_date:year'}" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Kanban -->
|
||||
<record id="view_kanban_res_partner" model="ir.ui.view">
|
||||
<field name="name">res.partner.kanban.inherit</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref ="base.res_partner_kanban_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="city" position="after">
|
||||
<field name="full_contact_adress" />
|
||||
</field>
|
||||
<xpath expr="//div[@class='oe_kanban_details']/ul/li[4]" position="replace">
|
||||
<li><field name="full_contact_adress" /></li>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_kanban_details']/ul/li[5]" position="attributes">
|
||||
<attribute name="style">display: none;</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@class='oe_kanban_details']/ul/li[6]" position="attributes">
|
||||
<attribute name="style">display: none;</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Calendar -->
|
||||
<act_window id="contacts.action_contacts" name="Contacts"
|
||||
res_model="res.partner" view_mode="kanban,form,calendar,graph,pivot" />
|
||||
|
||||
<record id="view_calendar_res_partner" model="ir.ui.view">
|
||||
<field name="name">res.partner.calendar</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar date_start="contact_date" mode="month"
|
||||
display="First contact : [name]" >
|
||||
<field name="name" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Graph -->
|
||||
<record id="view_graph_res_partner" model="ir.ui.view">
|
||||
<field name="name">res.partner.graph</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph type="bar">
|
||||
<field name="is_coworker" />
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_pivot_res_partner" model="ir.ui.view">
|
||||
<field name="name">pivot</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="titre pivot">
|
||||
<field name="title" type="col" />
|
||||
<field name="contact_date" interval="week" />
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
3
coworking_event/__init__.py
Normal file
3
coworking_event/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models, wizard
|
34
coworking_event/__manifest__.py
Normal file
34
coworking_event/__manifest__.py
Normal file
@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017 Firstname Lastname <firstname.lastname@company.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
'name': 'Coworking event',
|
||||
'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/event_menu.xml',
|
||||
'views/event_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'wizard/coworking_event_weekly_views.xml'],
|
||||
'depends': ['coworking_coworker']
|
||||
}
|
3
coworking_event/models/__init__.py
Normal file
3
coworking_event/models/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""dd"""
|
||||
from . import event, res_partner
|
89
coworking_event/models/event.py
Normal file
89
coworking_event/models/event.py
Normal file
@ -0,0 +1,89 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Event module """
|
||||
|
||||
from datetime import datetime
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class Event(models.Model):
|
||||
""" Event model """
|
||||
_name = 'coworking.event'
|
||||
_description = 'Event model definition'
|
||||
_rec_name = 'title'
|
||||
_order = 'id asc'
|
||||
|
||||
title = fields.Char(required=True)
|
||||
|
||||
manager_id = fields.Many2one('res.partner', '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('res.partner', 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 event starts this week """
|
||||
for event in self:
|
||||
date_start = fields.Datetime.from_string(event.date_start)
|
||||
week_start = date_start.isocalendar()[1]
|
||||
event.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 event in self.search([]):
|
||||
date_start = fields.Datetime.from_string(event.date_start)
|
||||
week_start = date_start.isocalendar()[1]
|
||||
if datetime.now().isocalendar()[1] == week_start:
|
||||
res_ids.append(event.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 event in self:
|
||||
event.participants_count = len(event.participants_ids)
|
||||
|
||||
@api.constrains('statut', 'participants_ids')
|
||||
def _check_if_confirmed(self):
|
||||
"""Test si participants_ids est confirmed"""
|
||||
for event in self:
|
||||
if event.participants_ids and event.statut == 'draft':
|
||||
raise models.ValidationError(_('You can have subscribed people '
|
||||
'if event 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"""
|
||||
for event in self:
|
||||
if event.date_start > event.date_end:
|
||||
raise ValidationError(_('End date most be supperior to to start date'))
|
||||
|
||||
@api.depends('date_start', 'date_end')
|
||||
def _compute_duration(self):
|
||||
for event in self:
|
||||
if event.date_start and event.date_end:
|
||||
date_end_py = fields.Datetime.from_string(event.date_end)
|
||||
date_start_py = fields.Datetime.from_string(event.date_start)
|
||||
delta = date_end_py - date_start_py
|
||||
event.duration = delta.days * 24.0 + round(float(delta.seconds) / 3600.0)
|
||||
else:
|
||||
event.duration = 0.0
|
22
coworking_event/models/res_partner.py
Normal file
22
coworking_event/models/res_partner.py
Normal file
@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworker adaptations """
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
class ResPartner(models.Model):
|
||||
""" Coworker adaptations """
|
||||
_inherit = 'res.partner'
|
||||
|
||||
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)
|
2
coworking_event/security/ir.model.access.csv
Normal file
2
coworking_event/security/ir.model.access.csv
Normal file
@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
acess_coworker_group_user,Access COWORKER Member User,model_coworking_event,base.group_user,1,1,1,1
|
|
3
coworking_event/tests/__init__.py
Normal file
3
coworking_event/tests/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_coworking_event
|
20
coworking_event/tests/test_coworking_event.py
Normal file
20
coworking_event/tests/test_coworking_event.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworking cowoker testing module """
|
||||
|
||||
from datetime import date
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
class TestCoworkingEvent(TransactionCase):
|
||||
""" Coworking cowoker testing """
|
||||
|
||||
# def setUp(self, *args, **kwargs):
|
||||
# """ Bootstrap testing """
|
||||
# super(TestCoworkingEvent, self).setUp(*args, **kwargs)
|
||||
# data = {'title': 'Mon evenement', 'is_coworker': True}
|
||||
# self.homer = self.env['res.partner'].create(data)
|
||||
|
||||
def test_contact_date(self):
|
||||
pass
|
14
coworking_event/views/event_menu.xml
Normal file
14
coworking_event/views/event_menu.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?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="tree,form,calendar"
|
||||
context="{'search_default_status_confirmed': True, 'search_default_status_draft': True}" />
|
||||
<!-- Menu item to open Event list -->
|
||||
<menuitem id="event_topmenu" name="Event" />
|
||||
<menuitem id="event_menu" name="Events" action="event_action"
|
||||
parent="event_topmenu" sequence="1" />
|
||||
|
||||
</odoo>
|
96
coworking_event/views/event_views.xml
Normal file
96
coworking_event/views/event_views.xml
Normal file
@ -0,0 +1,96 @@
|
||||
<?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">
|
||||
<header>
|
||||
<field name="statut" widget="statusbar" clickable="1" />
|
||||
</header>
|
||||
<sheet>
|
||||
<group name="group_top">
|
||||
<group name="group_left">
|
||||
<field name="title" />
|
||||
<field name="manager_id" />
|
||||
<field name="date_start" />
|
||||
<field name="starts_this_week" attrs="{'invisible': [('date_start', '=', True)]}" />
|
||||
<field name="date_end" />
|
||||
<field name="duration" widget="float_time" />
|
||||
<field name="description" />
|
||||
<field name="participants_ids" widget="many2many_tags"
|
||||
options="{'no_create': true}" />
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree -->
|
||||
<record id="view_tree_coworker" model="ir.ui.view">
|
||||
<field name="name">event Tree</field>
|
||||
<field name="model">coworking.event</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="date_start asc">
|
||||
<field name="title" />
|
||||
<field name="manager_id" />
|
||||
<field name="date_start" />
|
||||
<field name="participants_count" />
|
||||
<field name="statut" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search -->
|
||||
<record id="view_search_event" model="ir.ui.view">
|
||||
<field name="name">Event Search</field>
|
||||
<field name="model">coworking.event</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="title" />
|
||||
<field name="manager_id" />
|
||||
|
||||
<filter name="status_confirmed" string="Confirmed"
|
||||
domain="[('statut','=','confirmed')]" />
|
||||
<filter name="status_draft" string="Draft"
|
||||
domain="[('statut','=','draft')]" />
|
||||
<filter name="canceled" string="Canceled"
|
||||
domain="[('statut','=','canceled')]" />
|
||||
|
||||
<separator />
|
||||
<filter name="this_week" string="Starts this week"
|
||||
domain="[('starts_this_week','=', True)]" />
|
||||
|
||||
<filter name="this_30_month" string="Starts 30 month"
|
||||
domain="[('date_start','<=', datetime.datetime.combine(context_today() + datetime.timedelta(days=30), datetime.time(23,59,59))),
|
||||
('date_start','>=', datetime.datetime.combine(context_today(), datetime.time(0,0,0)))]" />
|
||||
|
||||
<filter name="group_status" string="Group status"
|
||||
context="{'group_by': 'statut'}" />
|
||||
<filter name="group_manager_id" string="Group manager"
|
||||
context="{'group_by': 'manager_id'}" />
|
||||
<filter name="group_years_start" string="Group years start"
|
||||
context="{'group_by': 'date_start:year'}" />
|
||||
|
||||
<filter name="group_month" string="Group month"
|
||||
context="{'group_by': 'date_start:month'}" />
|
||||
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<!-- Calendar -->
|
||||
<record id="view_calendar_event" model="ir.ui.view">
|
||||
<field name="name">Event Calendar</field>
|
||||
<field name="model">coworking.event</field>
|
||||
<field name="arch" type="xml">
|
||||
<calendar date_start="date_start" date_stop="date_end"
|
||||
display="[title]" >
|
||||
<field name="title" />
|
||||
</calendar>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
22
coworking_event/views/res_partner_views.xml
Normal file
22
coworking_event/views/res_partner_views.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
<!-- Form -->
|
||||
<record id="view_form_res_partner" model="ir.ui.view">
|
||||
<field name="name">Res_partner Form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref ="base.view_partner_form" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Events" name="Events">
|
||||
<group name="events">
|
||||
<field name="manager_event_ids"
|
||||
context="{'default_manager_id': active_id}" />
|
||||
<field name="event_ids" />
|
||||
<field name="events_coworker_count" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
2
coworking_event/wizard/__init__.py
Normal file
2
coworking_event/wizard/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import coworking_event_weekly
|
65
coworking_event/wizard/coworking_event_weekly.py
Normal file
65
coworking_event/wizard/coworking_event_weekly.py
Normal file
@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Weekly massive event creation module """
|
||||
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class CoworkingEventWeekly(models.TransientModel):
|
||||
""" Weekly massive event creation """
|
||||
_name = 'coworking.event.weekly'
|
||||
_description = 'Weekly massive event creation'
|
||||
|
||||
title = fields.Char(required=True)
|
||||
manager_id = fields.Many2one('res.partner', string='Manager',
|
||||
required=True)
|
||||
date_start_recurence = fields.Datetime('Date start', required=True)
|
||||
date_stop_recurence = fields.Datetime('Date stop', required=True)
|
||||
duration = fields.Float(required=True)
|
||||
|
||||
@api.constrains('date_start_recurence', 'date_stop_recurence')
|
||||
def _check_dates(self):
|
||||
""" Check date coherence """
|
||||
for weekly in self:
|
||||
if weekly.date_start_recurence > weekly.date_stop_recurence:
|
||||
raise ValidationError(_('Please check you dates.'))
|
||||
|
||||
@api.multi
|
||||
def weekly_create(self):
|
||||
""" Create multiple events repeated weekly, according to dates """
|
||||
self.ensure_one()
|
||||
# 5 - Rediriger vers la liste des événements (en automatique)
|
||||
# _LOGGER.warning()
|
||||
date_start_py = fields.Datetime.from_string(self.date_start_recurence)
|
||||
duration_delta = timedelta(hours=self.duration)
|
||||
date_stop_py = fields.Datetime.from_string(self.date_stop_recurence)
|
||||
delta = date_stop_py - date_start_py
|
||||
|
||||
wdelta = timedelta(days=7)
|
||||
|
||||
for week_number in xrange(delta.days / 7 + 1):
|
||||
if week_number == 0:
|
||||
date_start = self.date_start_recurence
|
||||
date_stop = fields.Datetime.to_string(date_start_py + duration_delta)
|
||||
else:
|
||||
date_start = fields.Datetime.from_string(self.date_start_recurence) +\
|
||||
wdelta * week_number
|
||||
date_stop = fields.Datetime.to_string(date_start + duration_delta)
|
||||
date_start = fields.Datetime.to_string(date_start)
|
||||
self.env['coworking.event'].create({
|
||||
'title': self.title,
|
||||
'date_start': date_start,
|
||||
'date_end': date_stop,
|
||||
'manager_id': self.manager_id.id
|
||||
})
|
||||
event_action = self.env.ref('coworking_event.event_action')
|
||||
return {
|
||||
'type': event_action.type,
|
||||
'name': event_action.name,
|
||||
'res_model': event_action.res_model,
|
||||
'target': 'main',
|
||||
'view_mode': event_action.view_mode
|
||||
}
|
46
coworking_event/wizard/coworking_event_weekly_views.xml
Normal file
46
coworking_event/wizard/coworking_event_weekly_views.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Form -->
|
||||
<record id="view_form_weekly_event" model="ir.ui.view">
|
||||
<field name="name">Event Weekly Form</field>
|
||||
<field name="model">coworking.event.weekly</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="event">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="title" />
|
||||
<field name="manager_id" />
|
||||
<field name="date_start_recurence" />
|
||||
<field name="date_stop_recurence" />
|
||||
<field name="duration" widget="float_time" />
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button type="object" name="weekly_create" string="Create"
|
||||
class="oe_highlight" />
|
||||
<button string="Close" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action -->
|
||||
<!-- <record id="weekly_event_action" model="ir.actions.act_window">
|
||||
<field name="name">Weekly event</field>
|
||||
<field name="res_model">coworking.event.weekly</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="coworking_event.view_form_weekly_event" />
|
||||
<field name="target">new</field>
|
||||
</record> -->
|
||||
|
||||
<act_window id="weekly_event_action" name="Weekly event"
|
||||
res_model="coworking.event.weekly" view_mode="form"
|
||||
target="new" />
|
||||
|
||||
<!-- Menu -->
|
||||
<menuitem id="weekly_event_menu" name="Weekly events" action="weekly_event_action"
|
||||
parent="event_topmenu" sequence="5" />
|
||||
|
||||
</odoo>
|
@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import coworker
|
||||
from . import models
|
33
coworking_relation/__manifest__.py
Normal file
33
coworking_relation/__manifest__.py
Normal file
@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017 Firstname Lastname <firstname.lastname@company.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
'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_menu.xml',
|
||||
'views/relation_views.xml',
|
||||
'views/res_partner_views.xml'],
|
||||
'depends': ['coworking_coworker', 'coworking_event']
|
||||
}
|
3
coworking_relation/models/__init__.py
Normal file
3
coworking_relation/models/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""dd"""
|
||||
from . import relation, res_partner
|
32
coworking_relation/models/relation.py
Normal file
32
coworking_relation/models/relation.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworker relation """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class CoworkerRelation(models.Model):
|
||||
"""Coworker relation model """
|
||||
_name = 'coworking.relation'
|
||||
_description = 'relation model definition'
|
||||
_order = 'id asc'
|
||||
|
||||
name = fields.Char()
|
||||
|
||||
coworker1 = fields.Many2one(
|
||||
'res.partner', 'Coworker 1', index=True, required=True,
|
||||
domain="[('is_coworker', '=', True)]"
|
||||
)
|
||||
coworker2 = fields.Many2one(
|
||||
'res.partner', 'Coworker 2', index=True, required=True,
|
||||
domain="[('is_coworker', '=', True)]"
|
||||
)
|
||||
relation = fields.Char(index=True, required=True)
|
||||
|
||||
|
||||
@api.constrains('coworker1', 'coworker2')
|
||||
def _check_if_coworker_is_same(self):
|
||||
"""Test si coworker1 est identique à coworker2"""
|
||||
if self.coworker1 == self.coworker2:
|
||||
raise ValidationError(_('Coworker1 is same coworker2'))
|
40
coworking_relation/models/res_partner.py
Normal file
40
coworking_relation/models/res_partner.py
Normal file
@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworker adaptations """
|
||||
|
||||
import logging
|
||||
from odoo import models, fields, api
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class ResPartner(models.Model):
|
||||
""" Coworker adaptations """
|
||||
_inherit = 'res.partner'
|
||||
|
||||
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')
|
||||
#Relation fields
|
||||
|
||||
coworker_relation_ids = fields.One2many(
|
||||
string="Relations",
|
||||
comodel_name="coworking.relation",
|
||||
inverse_name="coworker2",
|
||||
compute="_compute_coworker_relation_ids")
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
def _compute_coworker_relation_ids(self):
|
||||
""" Computes coworker1_relation_ids and coworker2_relation_ids """
|
||||
for coworker in self:
|
||||
relation_model = self.env['coworking.relation']
|
||||
domain = ('|', ['coworker1', '=', coworker.id],
|
||||
['coworker2', '=', coworker.id])
|
||||
coworker.coworker_relation_ids = relation_model.search(domain)
|
2
coworking_relation/security/ir.model.access.csv
Normal file
2
coworking_relation/security/ir.model.access.csv
Normal file
@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
acess_coworker_group_user,Access COWORKER Member User,model_coworking_relation,base.group_user,1,1,1,1
|
|
3
coworking_relation/tests/__init__.py
Normal file
3
coworking_relation/tests/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_coworking_relation
|
29
coworking_relation/tests/test_coworking_relation.py
Normal file
29
coworking_relation/tests/test_coworking_relation.py
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworking cowoker testing module """
|
||||
|
||||
from datetime import date
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
class TestCoworkingRelation(TransactionCase):
|
||||
""" Coworking cowoker testing """
|
||||
|
||||
def test_if_coworker_is_same(self):
|
||||
""" Test coworker1.id and coworker2.id is identical """
|
||||
coworker1 = self.env['res.partner'].create({'name': 'Marge Simpson',
|
||||
'is_coworker': True})
|
||||
coworker2 = self.env['res.partner'].create({'name': 'Bart Simpson',
|
||||
'is_coworker': True})
|
||||
|
||||
relation = self.env['coworking.relation'].create({'coworker1': coworker1.id,
|
||||
'coworker2': coworker2.id,
|
||||
'relation': 'Mère'})
|
||||
self.assertEqual(relation.relation, u'Mère')
|
||||
|
||||
with self.assertRaises(ValidationError) as err:
|
||||
self.env['coworking.relation'].create({'coworker1': coworker1.id,
|
||||
'coworker2': coworker1.id,
|
||||
'relation': 'Mère'})
|
||||
self.assertIn(u'Coworker1 is same coworker2', unicode(err.exception))
|
12
coworking_relation/views/relation_menu.xml
Normal file
12
coworking_relation/views/relation_menu.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Action to open Coworkers list -->
|
||||
<act_window id="relation_action" name="Relation"
|
||||
res_model="coworking.relation" view_mode="tree" />
|
||||
<!-- Menu item to open Event list -->
|
||||
<menuitem id="coworker_relation_menu" name="Relations" action="relation_action"
|
||||
parent="contacts.menu_contacts" sequence="2" />
|
||||
|
||||
</odoo>
|
61
coworking_relation/views/relation_views.xml
Normal file
61
coworking_relation/views/relation_views.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Form -->
|
||||
<record id="view_form_relation" model="ir.ui.view">
|
||||
<field name="name">Relation Form</field>
|
||||
<field name="model">coworking.relation</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="event">
|
||||
<sheet>
|
||||
<group name="group_top">
|
||||
<group name="group_left">
|
||||
<field name="coworker1" domain="[('id', '!=', coworker2), ('is_coworker', '=', True)]" />
|
||||
<field name="coworker2" domain="[('id', '!=', coworker1), ('is_coworker', '=', True)]" />
|
||||
<field name="relation" />
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree -->
|
||||
<record id="view_tree_relation" model="ir.ui.view">
|
||||
<field name="name">relation Tree</field>
|
||||
<field name="model">coworking.relation</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="True">
|
||||
<field name="coworker1" domain="[('id', '!=', coworker2), ('is_coworker', '=', True)]" />
|
||||
<field name="coworker2" domain="[('id', '!=', coworker1), ('is_coworker', '=', True)]" />
|
||||
<field name="relation" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Search -->
|
||||
<record id="view_search_relation" model="ir.ui.view">
|
||||
<field name="name">relation Search</field>
|
||||
<field name="model">coworking.relation</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="coworker1" />
|
||||
<field name="coworker2" />
|
||||
<field name="relation" />
|
||||
|
||||
<separator />
|
||||
|
||||
<filter name="group_relation" string="Group relation"
|
||||
context="{'group_by': 'relation'}" />
|
||||
|
||||
<filter name="group_coworker1" string="Group coworker1"
|
||||
context="{'group_by': 'coworker1'}" />
|
||||
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
21
coworking_relation/views/res_partner_views.xml
Normal file
21
coworking_relation/views/res_partner_views.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Form -->
|
||||
<record id="view_form_res_partner" model="ir.ui.view">
|
||||
<field name="name">Res_partner Form adaptations</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref ="base.view_partner_form" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Relation" name="Relation">
|
||||
<group name="relation">
|
||||
<field name="coworker_relation_ids" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
@ -1,39 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Coworker module """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class Coworker(models.Model):
|
||||
""" Coworker model """
|
||||
_name = 'coworking.coworker'
|
||||
_description = 'Coworker model definition'
|
||||
_order = 'id desc'
|
||||
|
||||
name = fields.Char(required=True)
|
||||
firstname = fields.Char('First name', required=True)
|
||||
coworker_type = fields.Selection([('staffer', 'Staffer'),
|
||||
('worker', 'Worker'), ('member', 'Member'),
|
||||
('volunteer', 'Volunteer'),
|
||||
('visitor', 'Visitor')])
|
||||
company_name = fields.Char('Company')
|
||||
job = fields.Char()
|
||||
contact_date = fields.Date(default=fields.Date.context_today)
|
||||
street = fields.Char()
|
||||
contact_zip = fields.Char()
|
||||
city = fields.Char()
|
||||
phone_number = fields.Char()
|
||||
gsm = fields.Char('GSM')
|
||||
email = fields.Char()
|
||||
url = fields.Char('URL')
|
||||
note = fields.Text()
|
||||
|
||||
is_done = fields.Boolean('Done?')
|
||||
is_active = fields.Boolean('Active?', default=True)
|
||||
|
||||
|
||||
@api.constrains('contact_date')
|
||||
def _check_contact_date(self):
|
||||
if self.contact_date > fields.Date.context_today(self):
|
||||
raise ValidationError(_('Date most be egual of inferior to to day'))
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Action to open Coworkers list -->
|
||||
<act_window id="coworker_action" name="Coworkers"
|
||||
res_model="coworking.coworker" view_mode="tree,form" />
|
||||
<!-- Menu item to open Coworkers list -->
|
||||
<menuitem id="coworker_menu" name="Coworkers" action="coworker_action" />
|
||||
|
||||
</odoo>
|
Loading…
Reference in New Issue
Block a user