This commit is contained in:
michel 2017-11-28 17:15:18 +01:00
parent 2411fdb93c
commit 2a1e846304
8 changed files with 42 additions and 17 deletions

View File

@ -34,9 +34,29 @@ class ResPartner(models.Model):
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

View File

@ -42,9 +42,14 @@
<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)]" />
<separator />
<filter name="group_month" string="Month"
context="{'group_by': 'contact_date:month'}" />
<filter name="group_year" string="Year"
@ -101,12 +106,11 @@
</record>
<record id="view_pivot_res_partner" model="ir.ui.view">
<field name="name">res.partner.pivot</field>
<field name="name">pivot</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<pivot>
<field name="is_coworker" type="col" />
<field name="user_id" />
<pivot string="titre pivot">
<field name="title" type="col" />
<field name="contact_date" interval="week" />
</pivot>
</field>

View File

@ -73,8 +73,9 @@ 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"""
if self.date_start > self.date_end:
raise ValidationError(_('End date most be supperior to to start date'))
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):

View File

@ -14,7 +14,7 @@ class CoworkingEventWeekly(models.TransientModel):
_description = 'Weekly massive event creation'
title = fields.Char(required=True)
manager_id = fields.Many2one('coworking.res_partner', string='Manager',
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)

View File

@ -26,7 +26,7 @@
'application': False,
'installable': True,
'data': ['security/ir.model.access.csv',
# 'views/relation_menu.xml',
'views/relation_menu.xml',
'views/relation_views.xml',
'views/res_partner_views.xml'],
'depends': ['coworking_coworker']

View File

@ -15,12 +15,12 @@ class CoworkerRelation(models.Model):
name = fields.Char()
coworker1 = fields.Many2one(
'coworking.coworker', 'Coworker 1', index=True, required=True,
domain="[('coworker_type', 'in', ['staffer', 'member', 'worker', 'volunteer', 'visitor'])]"
'res.partner', 'Coworker 1', index=True, required=True,
domain="[('is_coworker', '=', True)]"
)
coworker2 = fields.Many2one(
'coworking.coworker', 'Coworker 2', index=True, required=True,
domain="[('coworker_type', 'in', ['staffer', 'member', 'worker', 'volunteer', 'visitor'])]"
'res.partner', 'Coworker 2', index=True, required=True,
domain="[('is_coworker', '=', True)]"
)
relation = fields.Char(index=True, required=True)

View File

@ -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="coworking_coworker.coworker_menu" sequence="2" />
parent="contacts.menu_contacts" sequence="2" />
</odoo>

View File

@ -11,8 +11,8 @@
<sheet>
<group name="group_top">
<group name="group_left">
<field name="coworker1" domain="[('id', '!=', coworker2)]" />
<field name="coworker2" domain="[('id', '!=', coworker1)]" />
<field name="coworker1" domain="['&amp;', ('id', '!=', coworker2), ('is_coworker', '=', True)]" />
<field name="coworker2" domain="['&amp;', ('id', '!=', coworker1), ('is_coworker', '=', True)]" />
<field name="relation" />
</group>
</group>