forked from Yaltik/golem
[REF]GOLEM Resource : new calendar and list of reservations should be on resource, not on reservation (+code refactoring)
This commit is contained in:
parent
b3705b95ef
commit
465a25de6e
@ -20,7 +20,7 @@
|
||||
'name': 'GOLEM non-profit resources',
|
||||
'summary': 'GOLEM resources management',
|
||||
'description': ''' GOLEM resources management ''',
|
||||
'version': '10.0.1.7.0',
|
||||
'version': '10.0.1.8.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
""" GOLEM Resources management """
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@ -44,12 +44,41 @@ class GolemResource(models.Model):
|
||||
|
||||
avaibility_start = fields.Date(required=True, string='Availibility start date')
|
||||
avaibility_stop = fields.Date(required=True, string='Availibility stop date')
|
||||
availibility_24_7 = fields.Boolean(string='24/7 availibility')
|
||||
timetable_ids = fields.One2many('golem.resource.timetable', 'resource_id',
|
||||
string='Availibility timetable')
|
||||
reservation_ids = fields.One2many('golem.resource.reservation', 'resource_id',
|
||||
string='Reservations')
|
||||
reservation_count = fields.Integer(compute='_compute_reservation_count')
|
||||
|
||||
availibility_24_7 = fields.Boolean(string='24/7 availibility')
|
||||
@api.depends('reservation_ids')
|
||||
def _compute_reservation_count(self):
|
||||
for resource in self:
|
||||
resource.reservation_count = len(resource.reservation_ids)
|
||||
|
||||
@api.multi
|
||||
def reservation_calendar(self):
|
||||
""" current resource reservation calendar """
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Resource Reservation'),
|
||||
'view_mode': 'calendar',
|
||||
'res_model': 'golem.resource.reservation',
|
||||
'context': {'search_default_resource_id': self[0].id},
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def reserveration_list(self):
|
||||
""" current resource reservation list """
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': _('Resource Reservation list'),
|
||||
'view_mode': 'tree',
|
||||
'res_model': 'golem.resource.reservation',
|
||||
'context': {'search_default_resource_id': self[0].id},
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def active_toggle(self):
|
||||
|
@ -67,8 +67,6 @@ class GolemResourceReservation(models.Model):
|
||||
|
||||
rejection_reason = fields.Text(readonly=True, track_visibility='onchange')
|
||||
|
||||
resource_reservation_count = fields.Integer(compute='_reservation_count')
|
||||
|
||||
@api.depends('resource_id', 'date')
|
||||
def _compute_name(self):
|
||||
""" Computes reservation name """
|
||||
@ -203,39 +201,3 @@ class GolemResourceReservation(models.Model):
|
||||
'please choose another périod before confirming.')
|
||||
raise ValidationError(verr.format(other_res.date_start,
|
||||
other_res.date_stop))
|
||||
@api.multi
|
||||
def reservation_calendar(self):
|
||||
""" current resource reservation calendar """
|
||||
self.ensure_one()
|
||||
calendar_view = {
|
||||
'name': ('Resource Reservation list'),
|
||||
'view_mode': 'calendar',
|
||||
'res_model': 'golem.resource.reservation',
|
||||
'view_id': False,
|
||||
'domain': [('resource_id', '=', self.resource_id.id)],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'current'
|
||||
}
|
||||
return calendar_view
|
||||
|
||||
@api.multi
|
||||
def reserveration_list(self):
|
||||
""" current resource reservation list """
|
||||
self.ensure_one()
|
||||
tree_view = {
|
||||
'name': ('Resource Reservation list'),
|
||||
'view_mode': 'tree',
|
||||
'res_model': 'golem.resource.reservation',
|
||||
'view_id': False,
|
||||
'domain': [('resource_id', '=', self.resource_id.id)],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'current'
|
||||
}
|
||||
return tree_view
|
||||
|
||||
@api.multi
|
||||
@api.depends('resource_id')
|
||||
def _reservation_count(self):
|
||||
for reservation in self:
|
||||
reservation.resource_reservation_count = reservation.search_count([
|
||||
('resource_id', '=', reservation.resource_id.id)])
|
||||
|
@ -70,17 +70,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="state" widget="statusbar" />
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button class="oe_stat_button" icon="fa-list"
|
||||
name="reserveration_list" type="object">
|
||||
<field string="Reservation" name="resource_reservation_count"
|
||||
widget="statinfo"/>
|
||||
</button>
|
||||
<button class="oe_stat_button" icon="fa-calendar"
|
||||
name="reservation_calendar" type="object">
|
||||
<label string="Calendar"/>
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<group string="Resource">
|
||||
<field name="id" invisible="1" />
|
||||
|
@ -49,6 +49,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="active" widget="boolean_button"
|
||||
options="{'terminology': 'archive'}" />
|
||||
</button>
|
||||
<button class="oe_stat_button" icon="fa-list"
|
||||
name="reserveration_list" type="object">
|
||||
<field string="Reservations" name="reservation_count"
|
||||
widget="statinfo"/>
|
||||
</button>
|
||||
<button class="oe_stat_button" icon="fa-calendar"
|
||||
name="reservation_calendar" type="object" string="Calendar" />
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
|
Loading…
Reference in New Issue
Block a user