[ADD]GOLEM Activity Sessions management on smart button, own tree, form , filters
This commit is contained in:
parent
03ed5e1719
commit
b2a1e86e67
18
golem_activity_session/__init__.py
Normal file
18
golem_activity_session/__init__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from . import models
|
30
golem_activity_session/__openerp__.py
Normal file
30
golem_activity_session/__openerp__.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'GOLEM Activity Sessions',
|
||||||
|
'summary': 'GOLEM Activities Session management',
|
||||||
|
'description': ''' Non-profit french MJC activies session management ''',
|
||||||
|
'version': '0.1',
|
||||||
|
'category': 'Non-profit management',
|
||||||
|
'author': 'Fabien Bourgeois',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'application': False,
|
||||||
|
'installable': True,
|
||||||
|
'depends': ['golem_activity'],
|
||||||
|
'data': ['views/golem_activity_view.xml']
|
||||||
|
}
|
18
golem_activity_session/models/__init__.py
Normal file
18
golem_activity_session/models/__init__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from . import golem_activity_session
|
80
golem_activity_session/models/golem_activity_session.py
Normal file
80
golem_activity_session/models/golem_activity_session.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# copyright 2016 fabien bourgeois <fabien@yaltik.com>
|
||||||
|
#
|
||||||
|
# this program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the gnu affero general public license as
|
||||||
|
# published by the free software foundation, either version 3 of the
|
||||||
|
# license, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# this program is distributed in the hope that it will be useful,
|
||||||
|
# but without any warranty; without even the implied warranty of
|
||||||
|
# merchantability or fitness for a particular purpose. see the
|
||||||
|
# gnu affero general public license for more details.
|
||||||
|
#
|
||||||
|
# you should have received a copy of the gnu affero general public license
|
||||||
|
# along with this program. if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from openerp import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
|
class GolemActivity(models.Model):
|
||||||
|
_inherit = 'golem.activity'
|
||||||
|
|
||||||
|
session_count = fields.Integer('Sessions',
|
||||||
|
compute='_compute_session_count')
|
||||||
|
|
||||||
|
@api.one
|
||||||
|
def _compute_session_count(self):
|
||||||
|
dmn = [('activity_id', '=', self.id)]
|
||||||
|
cnt = self.env['golem.activity.session'].search_count(dmn)
|
||||||
|
self.session_count = cnt
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def button_session(self):
|
||||||
|
self.ensure_one()
|
||||||
|
return {'name': _('Activity Sessions'),
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'golem.activity.session',
|
||||||
|
'view_mode': 'tree,form',
|
||||||
|
'context': {'default_activity_id': self.id,
|
||||||
|
'default_animator_id': self.animator_id.id},
|
||||||
|
'domain': [('activity_id', '=', self.id)]}
|
||||||
|
|
||||||
|
|
||||||
|
class GolemActivitySession(models.Model):
|
||||||
|
_name = 'golem.activity.session'
|
||||||
|
_description = 'GOLEM Activities Sessions'
|
||||||
|
|
||||||
|
name = fields.Char('Name', compute='_compute_name')
|
||||||
|
|
||||||
|
@api.depends('activity_id', 'weekday')
|
||||||
|
def _compute_name(self):
|
||||||
|
for s in self:
|
||||||
|
s.name = s.activity_id.activity_name
|
||||||
|
|
||||||
|
# TODO: reucrrence etc... to link with calendar.event
|
||||||
|
activity_id = fields.Many2one('golem.activity', string='Activité',
|
||||||
|
required=True)
|
||||||
|
animator_id = fields.Many2one('res.partner', string='Animator',
|
||||||
|
required=True)
|
||||||
|
is_recurrent = fields.Boolean('Is recurrent ?', default=False,
|
||||||
|
help="Work in progress")
|
||||||
|
weekday = fields.Selection([('mon', _('Monday')),
|
||||||
|
('tue', _('Tuesday')),
|
||||||
|
('wed', _('Wednesday')),
|
||||||
|
('thu', _('Thursday')),
|
||||||
|
('fri', _('Friday')),
|
||||||
|
('sat', _('Saturday')),
|
||||||
|
('sun', _('Sunday'))])
|
||||||
|
hour_start = fields.Float('Start time')
|
||||||
|
hour_end = fields.Float('End time')
|
||||||
|
note = fields.Text('Note')
|
||||||
|
|
||||||
|
@api.constrains('hour_start', 'hour_end')
|
||||||
|
def _check_period(self):
|
||||||
|
""" Check if end hour if after start hour """
|
||||||
|
for s in self:
|
||||||
|
if s.hour_start > s.hour_end:
|
||||||
|
raise models.ValidationError(_('Start of the period cannot be '
|
||||||
|
'after end of the period.'))
|
105
golem_activity_session/views/golem_activity_view.xml
Normal file
105
golem_activity_session/views/golem_activity_view.xml
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Form -->
|
||||||
|
<record model="ir.ui.view" id="session_smart">
|
||||||
|
<field name="name">Add sessions management into smart button</field>
|
||||||
|
<field name="model">golem.activity</field>
|
||||||
|
<field name="inherit_id" ref="golem_activity.view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<div name="buttons" position="inside">
|
||||||
|
<button class="oe_inline oe_stat_button" type="object"
|
||||||
|
name="button_session" icon="fa-list">
|
||||||
|
<field string="Week sessions" name="session_count" widget="statinfo" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_form" model="ir.ui.view">
|
||||||
|
<field name="name">GOLEM Activity Sessions Form</field>
|
||||||
|
<field name="model">golem.activity.session</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<sheet>
|
||||||
|
<group string="Activity Session">
|
||||||
|
<group>
|
||||||
|
<field name="activity_id" />
|
||||||
|
<field name="animator_id" />
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="is_recurrent" readonly="True" />
|
||||||
|
<field name="weekday" />
|
||||||
|
<field name="hour_start" widget="float_time" />
|
||||||
|
<field name="hour_end" widget="float_time" />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="note" />
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Tree -->
|
||||||
|
<record id="family_tree" model="ir.ui.view">
|
||||||
|
<field name="name">Session list</field>
|
||||||
|
<field name="model">golem.activity.session</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree>
|
||||||
|
<field name="activity_id" />
|
||||||
|
<field name="animator_id" />
|
||||||
|
<field name="weekday" />
|
||||||
|
<field name="hour_start" />
|
||||||
|
<field name="hour_end" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Searches -->
|
||||||
|
<record id="searches" model="ir.ui.view">
|
||||||
|
<field name="name">GOLEM Activity Sessions Searches</field>
|
||||||
|
<field name="model">golem.activity.session</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<field name="activity_id" widget="many2one" />
|
||||||
|
<field name="animator_id" widget="many2one" />
|
||||||
|
<group string="Group By">
|
||||||
|
<filter name="group_weekday" string="By weekday"
|
||||||
|
context="{'group_by': 'weekday'}" />
|
||||||
|
<filter name="group_animator" string="By animator"
|
||||||
|
context="{'group_by': 'animator_id'}" />
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Actions -->
|
||||||
|
<act_window id="session_action_list" name="GOLEM Activities Sessions List"
|
||||||
|
res_model="golem.activity.session" view_mode="tree,form" />
|
||||||
|
<!-- Menus -->
|
||||||
|
<menuitem id="session_menu_list" name="Activities sessions"
|
||||||
|
parent="golem_activity.activity_menu" action="session_action_list"
|
||||||
|
sequence="10" />
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue
Block a user