Code cleaning and finalizing

This commit is contained in:
eloyoussef 2018-02-21 14:56:51 +01:00
parent 98c8ad3767
commit a0af3a680a
7 changed files with 32 additions and 30 deletions

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
#
# This program is free software: you can redistribute it and/or modify

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
#
# This program is free software: you can redistribute it and/or modify
@ -20,7 +21,7 @@
'summary': 'GOLEM activities queue',
'version': '10.0.2.1.0',
'category': 'GOLEM',
'author': 'Youssef Elouahby',
'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3',
'application': True,
'installable': True,

View File

@ -23,7 +23,7 @@ class GolemActivity(models.Model):
_inherit = 'golem.activity'
#ajout d'un champs O2M vers activity_id
#ajout d'un champs O2M vers activity_id de golem.activity.queue
activity_queue_ids = fields.One2many('golem.activity.queue',
'activity_id','Pending registration')
# un boolen pour determiner si une fille d'attente est autorisé

View File

@ -22,20 +22,15 @@ class GolemMember(models.Model):
""" GOLEM Member adaptations """
_inherit = 'golem.member'
#ajout d'un champs O2M vers member_id de golem.activity.queue
activity_queue_ids = fields.One2many('golem.activity.queue',
'member_id','Pending registration')
@api.onchange('activity_registration_ids')
def _checkRemain(self):
"""print "#####################################"
print len(self.activity_registration_ids)
for reservation in self.activity_registration_ids:
print reservation.activity_id.name"""
for reservation in self.activity_registration_ids:
activity = reservation.activity_id
"""print activity.name
print activity.places
print len(activity.activity_registration_ids)"""
if len(activity.activity_registration_ids) > activity.places and activity.queue_allowed:
#print("##vert##################")
warning_message = _('This activity : {} is already full, please'
' remove your registration and register in'
' the queue using the bellow button')
@ -45,27 +40,12 @@ class GolemMember(models.Model):
'message': warning_message.format(activity.name),
}
}
"""
print "######################################"
print reservation.activity_id.places
print "######################################"
print reservation.activity_id.places_remain
if len(self.activity_registration_ids) > self.places and self.queue_allowed:
return {
'warning' : {
'title' : _('Warning'),
'message': _('No remaining place, please register in the queue'),
}
}"""
def queue_register(self):
return {
'name' : _('Choose the activity to register in'),
'type' : 'ir.actions.act_window',
'res_model' : 'golem.activity.queue.choose.wizard',
'view_mode': 'form',#'context' :{'default_activity_id' : activity_id.id},
'domain' : [('activity_id.places_remain', '=', 0)],# activity_id.name)],#"('activity_id', '=', True)"'flags': {'action_buttons': True},
'view_mode': 'form',
'target': 'new',
}

View File

@ -25,15 +25,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="model">golem.activity</field>
<field name="inherit_id" ref="golem_activity.golem_activity_form" />
<field name="arch" type="xml">
<!--Ajout du case file sur activity form-->
<xpath expr="//field[@name='is_overbooked']" position="after">
<field name="queue_allowed"/>
</xpath>
<!--Ajout du bouton inscription en file d'attente sur activity form-->
<xpath expr="//field[@name='activity_registration_ids']" position="after">
<button class="oe_highlight" name="queue_register"
string="Register in the queue" type="object"
attrs="{'invisible':[('places_remain','>', 0)]}"/>
</xpath>
<!--onglet queue sur activity-->
<!--Ajout onglet queue sur activity form-->
<page name="invoicing" position="before">
<page name="queue" string="Queue">
<group>

View File

@ -22,15 +22,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<!-- add the queue registration button to member form-->
<record id="golem_member_form_inherit_golem_activity_queue"
model="ir.ui.view">
<field name="name">Add the queue registration button to member form</field>
<field name="name">Add the queue onglet and registration button to member form</field>
<field name="model">golem.member</field>
<field name="inherit_id" ref="golem_member.golem_member_form" />
<field name="arch" type="xml">
<!--Ajout bouton d'inscription en file d'attente sur member form-->
<xpath expr="//field[@name='activity_registration_ids']" position="after">
<group>
<button class="oe_highlight" name="queue_register" string="Register in the queue" type="object"/>
</group>
</xpath>
<!--Ajout onglet queue sur member form-->
<page name="activities" position="after">
<page name="queue" string="List of queues">
<group>
<field name="activity_queue_ids"
context="{'default_member_id': active_id}">
<tree>
<field name="activity_id" readonly="1" />
<field name="season_id" readonly="1" />
</tree>
</field>
</group>
</page>
</page>
</field>
</record>
</data>

View File

@ -26,6 +26,7 @@ class GolemActivityQueueChooseWizard(models.TransientModel):
activity_id = fields.Many2one("golem.activity")
def ChooseActivity(self):
self.ensure_one()
activityQueue = self[0]
@ -33,7 +34,8 @@ class GolemActivityQueueChooseWizard(models.TransientModel):
'name' : _('Register in the queue'),
'type' : 'ir.actions.act_window',
'res_model' : 'golem.activity.queue',
'view_mode': 'tree',#'context' :{'default_activity_id' : activity_id.id},
'view_mode': 'tree',#
'context' :{'default_activity_id' : activityQueue.activity_id.id},
'domain' : [('activity_id', '=',activityQueue.activity_id.id )],# activity_id.name)],#"('activity_id', '=', True)"
'flags': {'action_buttons': True},
'target': 'new',