Skip to content
Extraits de code Groupes Projets
Valider 30cb2939 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[cgscop #143 & #144] ajout convention régionale et automatisation de la mise à...

[cgscop #143 & #144] ajout convention régionale et automatisation de la mise à jour depuis l'organisme
parent 451592fc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -42,6 +42,9 @@ class CGScopCalendar(models.Model):
ur_financial_system_id = fields.Many2one(
comodel_name='ur.financial.system',
string='Dispositif Financier')
ur_regional_convention_id = fields.Many2one(
comodel_name='ur.regional.convention',
string='Convention Régionale')
ur_id = fields.Many2one(
'union.regionale',
string='Union Régionale',
......@@ -50,18 +53,27 @@ class CGScopCalendar(models.Model):
default=_default_ur)
ur_financial_system_nb = fields.Integer(
string="Nb Dispositifs Financiers",
compute="_compute_ur_financial_system_nb")
compute="_compute_ur_system_nb")
ur_regional_convention_nb = fields.Integer(
string="Nb conventions régionales",
compute="_compute_ur_system_nb")
# ------------------------------------------------------
# Compute
# ------------------------------------------------------
@api.depends('ur_id')
def _compute_ur_financial_system_nb(self):
def _compute_ur_system_nb(self):
for event in self:
# Calcul nombre de dispositifs financiers
financial_system = event.env['ur.financial.system'].search([
('ur_id', '=', event.ur_id.id)])
event.ur_financial_system_nb = len(
financial_system)
# Calcul nombre de conventions
regional_convention = event.env['ur.regional.convention'].search([
('ur_id', '=', event.ur_id.id)])
event.ur_regional_convention_nb = len(
regional_convention)
# ------------------------------------------------------
# Onchange
......@@ -85,6 +97,12 @@ class CGScopCalendar(models.Model):
if self.coop_id.city:
address += self.coop_id.city
self.location = address
if not self.coop_id.ur_financial_system_date or \
fields.Datetime.now() > self.coop_id.ur_financial_system_date:
self.ur_financial_system_id = self.coop_id.ur_financial_system_id
if not self.coop_id.ur_regional_convention_date or \
fields.Datetime.now() > self.coop_id.ur_regional_convention_date:
self.ur_regional_convention_id = self.coop_id.ur_regional_convention_id
# ------------------------------------------------------
# Fonction boutons
......@@ -109,4 +127,33 @@ class CGScopCalendar(models.Model):
'unit_amount': event.duration if not event.allday else 8.0,
'partner_id': event.coop_id.id,
})
# event.is_transfered = True
@api.multi
def duplicate_entry(self):
"""
Duplique la ligne de temps
"""
for event in self:
return {
'type': 'ir.actions.act_window',
'res_model': 'calendar.event',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
'context': {
'default_project_id': event.project_id.id,
'default_name': event.name,
'default_coop_id': event.coop_id.id,
'default_partner_ids': event.partner_ids.ids,
'default_start': event.start,
'default_duration': event.duration,
'default_stop': event.stop,
'default_allday': event.allday,
'default_type': event.type,
'default_ur_financial_system_id': event.ur_financial_system_id.id,
},
'flags': {'form': {
'action_buttons': False,
'options': {
'mode': 'edit'}}},
}
......@@ -18,10 +18,13 @@
<attribute name="invisible">True</attribute>
</field>
<field name="location" position="after">
<field name="ur_regional_convention_nb" invisible="1"/>
<field name="ur_financial_system_nb" invisible="1"/>
<field name="coop_id"/>
<field name="project_id"/>
<field name="type"/>
<field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}" />
<field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}" attrs="{'required':[('ur_financial_system_nb', '>', 0)], 'invisible':[('ur_financial_system_nb', '&lt;', 1)]}"/>
<field name="ur_regional_convention_id" options="{'no_open': True, 'no_create': True}" attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'invisible':[('ur_regional_convention_nb', '&lt;', 1)]}"/>
</field>
</field>
</record>
......@@ -36,6 +39,12 @@
<!-- Header -->
<sheet position="before">
<header>
<button
string="Dupliquer"
type="object"
name="duplicate_entry"
class="oe_highlight"
/>
<button
string="Transformer en ligne de temps"
type="object"
......@@ -91,7 +100,9 @@
<field name="type" />
<field name="location" />
<field name="ur_financial_system_nb" invisible="1"/>
<field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}" attrs="{'required':[('ur_financial_system_nb', '>', 0)]}"/>
<field name="ur_regional_convention_nb" invisible="1"/>
<field name="ur_financial_system_id" options="{'no_open': True, 'no_create': True}" attrs="{'required':[('ur_financial_system_nb', '>', 0)], 'invisible':[('ur_financial_system_id', '=', 0)]}"/>
<field name="ur_regional_convention_id" options="{'no_open': True, 'no_create': True}" attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'invisible':[('ur_regional_convention_nb', '=', 0)]}"/>
</group>
</group>
<group string="Informations complémentaires" name="event_extra_info">
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter