Compare commits
No commits in common. "V5_unit_test" and "V3" have entirely different histories.
V5_unit_te
...
V3
@ -26,7 +26,5 @@
|
||||
'application': True,
|
||||
'installable': True,
|
||||
'data': [],
|
||||
'demo': ['data/coworking_app_demo.xml'],
|
||||
|
||||
'depends': ['coworking_coworker', 'coworking_event']
|
||||
}
|
||||
|
@ -1,146 +0,0 @@
|
||||
<?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>
|
@ -25,5 +25,5 @@
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'depends': ['contacts']
|
||||
'depends': ['base']
|
||||
}
|
||||
|
@ -25,7 +25,8 @@
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'data': ['views/res_partner_views.xml'],
|
||||
|
||||
'data': ['security/ir.model.access.csv',
|
||||
'views/coworking_menu.xml',
|
||||
'views/coworker_views.xml'],
|
||||
'depends': ['coworking_base']
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import res_partner
|
||||
from . import coworker
|
||||
|
@ -10,9 +10,11 @@ class Coworker(models.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)
|
||||
name = fields.Char(required=True)
|
||||
firstname = fields.Char('First name', required=True)
|
||||
|
||||
coworker_type = fields.Selection([('staffer', 'Staffer'),
|
||||
|
@ -1,62 +0,0 @@
|
||||
# -*- 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
|
@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_coworking_coworker
|
@ -1,60 +0,0 @@
|
||||
# -*- 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,119 +0,0 @@
|
||||
<?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>
|
@ -28,7 +28,7 @@
|
||||
'data': ['security/ir.model.access.csv',
|
||||
'views/event_menu.xml',
|
||||
'views/event_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
'views/coworker_views.xml',
|
||||
'wizard/coworking_event_weekly_views.xml'],
|
||||
'depends': ['coworking_coworker']
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""dd"""
|
||||
from . import event, res_partner
|
||||
from . import event, coworker
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
class ResPartner(models.Model):
|
||||
class Coworker(models.Model):
|
||||
""" Coworker adaptations """
|
||||
_inherit = 'res.partner'
|
||||
_inherit = 'coworking.coworker'
|
||||
|
||||
manager_event_ids = fields.One2many('coworking.event', 'manager_id',
|
||||
string='Events managed')
|
@ -15,7 +15,7 @@ class Event(models.Model):
|
||||
|
||||
title = fields.Char(required=True)
|
||||
|
||||
manager_id = fields.Many2one('res.partner', 'Manager', index=True, 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',
|
||||
@ -28,7 +28,7 @@ class Event(models.Model):
|
||||
('confirmed', 'Confirmed'),
|
||||
('canceled', 'Canceled')], default='draft')
|
||||
|
||||
participants_ids = fields.Many2many('res.partner', string='Subscribers')
|
||||
participants_ids = fields.Many2many('coworking.coworker', string='Subscribers')
|
||||
participants_count = fields.Integer('Number of participants',
|
||||
compute='_compute_participants_count')
|
||||
|
||||
@ -73,9 +73,8 @@ class Event(models.Model):
|
||||
@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'))
|
||||
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):
|
||||
|
@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_coworking_event
|
@ -1,20 +0,0 @@
|
||||
# -*- 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
|
@ -1,11 +1,12 @@
|
||||
<?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" />
|
||||
<record id="view_form_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Form adaptations</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
<field name="inherit_id" ref ="coworking_coworker.view_form_coworker" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Events" name="Events">
|
||||
@ -19,4 +20,5 @@
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
@ -14,7 +14,7 @@ class CoworkingEventWeekly(models.TransientModel):
|
||||
_description = 'Weekly massive event creation'
|
||||
|
||||
title = fields.Char(required=True)
|
||||
manager_id = fields.Many2one('res.partner', string='Manager',
|
||||
manager_id = fields.Many2one('coworking.coworker', string='Manager',
|
||||
required=True)
|
||||
date_start_recurence = fields.Datetime('Date start', required=True)
|
||||
date_stop_recurence = fields.Datetime('Date stop', required=True)
|
||||
|
@ -28,6 +28,6 @@
|
||||
'data': ['security/ir.model.access.csv',
|
||||
'views/relation_menu.xml',
|
||||
'views/relation_views.xml',
|
||||
'views/res_partner_views.xml'],
|
||||
'depends': ['coworking_coworker', 'coworking_event']
|
||||
'views/coworker_views.xml'],
|
||||
'depends': ['coworking_coworker']
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""dd"""
|
||||
from . import relation, res_partner
|
||||
from . import relation, coworker
|
||||
|
@ -6,9 +6,9 @@ import logging
|
||||
from odoo import models, fields, api
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class ResPartner(models.Model):
|
||||
class Coworker(models.Model):
|
||||
""" Coworker adaptations """
|
||||
_inherit = 'res.partner'
|
||||
_inherit = 'coworking.coworker'
|
||||
|
||||
manager_event_ids = fields.One2many('coworking.event', 'manager_id',
|
||||
string='Events managed')
|
@ -15,12 +15,12 @@ class CoworkerRelation(models.Model):
|
||||
name = fields.Char()
|
||||
|
||||
coworker1 = fields.Many2one(
|
||||
'res.partner', 'Coworker 1', index=True, required=True,
|
||||
domain="[('is_coworker', '=', True)]"
|
||||
'coworking.coworker', 'Coworker 1', index=True, required=True,
|
||||
domain="[('coworker_type', 'in', ['staffer', 'member', 'worker', 'volunteer', 'visitor'])]"
|
||||
)
|
||||
coworker2 = fields.Many2one(
|
||||
'res.partner', 'Coworker 2', index=True, required=True,
|
||||
domain="[('is_coworker', '=', True)]"
|
||||
'coworking.coworker', 'Coworker 2', index=True, required=True,
|
||||
domain="[('coworker_type', 'in', ['staffer', 'member', 'worker', 'volunteer', 'visitor'])]"
|
||||
)
|
||||
relation = fields.Char(index=True, required=True)
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_coworking_relation
|
@ -1,29 +0,0 @@
|
||||
# -*- 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))
|
@ -3,10 +3,10 @@
|
||||
<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" />
|
||||
<record id="view_form_coworker" model="ir.ui.view">
|
||||
<field name="name">Coworker Form adaptations</field>
|
||||
<field name="model">coworking.coworker</field>
|
||||
<field name="inherit_id" ref ="coworking_coworker.view_form_coworker" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page string="Relation" name="Relation">
|
@ -7,6 +7,6 @@
|
||||
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" />
|
||||
parent="coworking_coworker.coworker_menu" sequence="2" />
|
||||
|
||||
</odoo>
|
||||
|
@ -11,8 +11,8 @@
|
||||
<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="coworker1" domain="[('id', '!=', coworker2)]" />
|
||||
<field name="coworker2" domain="[('id', '!=', coworker1)]" />
|
||||
<field name="relation" />
|
||||
</group>
|
||||
</group>
|
||||
@ -27,8 +27,8 @@
|
||||
<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="coworker1" domain="[('id', '!=', coworker2)]" />
|
||||
<field name="coworker2" domain="[('id', '!=', coworker1)]" />
|
||||
<field name="relation" />
|
||||
</tree>
|
||||
</field>
|
||||
|
Loading…
x
Reference in New Issue
Block a user