forked from Yaltik/golem
[IMP]GOLEM Activity Registrations migration from sessions to new pure activities
This commit is contained in:
parent
22d3f91e0c
commit
d1db9ae3b6
@ -49,17 +49,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<notebook>
|
<notebook>
|
||||||
<page string="Session">
|
<page string="Session">
|
||||||
<group>
|
<group>
|
||||||
<field name="is_recurrent" />
|
<group name="dates">
|
||||||
<field name="weekday"
|
<field name="is_recurrent" />
|
||||||
attrs="{'invisible': [('is_recurrent', '=', False)]}" />
|
<field name="weekday"
|
||||||
<field name="hour_start" widget="float_time"
|
attrs="{'invisible': [('is_recurrent', '=', False)]}" />
|
||||||
attrs="{'invisible': [('is_recurrent', '=', False)]}" />
|
<field name="hour_start" widget="float_time"
|
||||||
<field name="hour_end" widget="float_time"
|
attrs="{'invisible': [('is_recurrent', '=', False)]}" />
|
||||||
attrs="{'invisible': [('is_recurrent', '=', False)]}" />
|
<field name="hour_end" widget="float_time"
|
||||||
<field name="date_start"
|
attrs="{'invisible': [('is_recurrent', '=', False)]}" />
|
||||||
attrs="{'invisible': [('is_recurrent', '=', True)]}" />
|
<field name="date_start"
|
||||||
<field name="date_stop"
|
attrs="{'invisible': [('is_recurrent', '=', True)]}" />
|
||||||
attrs="{'invisible': [('is_recurrent', '=', True)]}" />
|
<field name="date_stop"
|
||||||
|
attrs="{'invisible': [('is_recurrent', '=', True)]}" />
|
||||||
|
</group>
|
||||||
|
<group name="places">
|
||||||
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page name="activity_info" string="Information">
|
<page name="activity_info" string="Information">
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'GOLEM Activity Session Member Registrations',
|
'name': 'GOLEM Activity Member Registrations',
|
||||||
'summary': 'GOLEM Activities Session Member Registrations management',
|
'summary': 'GOLEM Activities Member Registrations management',
|
||||||
'description': ''' Non-profit french MJC activities session member
|
'description': ''' Non-profit french MJC activity member registrations
|
||||||
registrations management ''',
|
management ''',
|
||||||
'version': '0.1',
|
'version': '0.1',
|
||||||
'category': 'GOLEM',
|
'category': 'GOLEM',
|
||||||
'author': 'Fabien Bourgeois',
|
'author': 'Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'application': False,
|
'application': False,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'depends': ['golem_activity_session', 'golem_member'],
|
'depends': ['golem_activity', 'golem_member'],
|
||||||
'data': ['views/golem_activity_session_registration_view.xml',
|
'data': ['views/golem_activity_session_registration_view.xml',
|
||||||
'views/golem_member_view.xml', 'views/golem_activity_view.xml']
|
'views/golem_member_view.xml', 'views/golem_activity_view.xml']
|
||||||
}
|
}
|
@ -21,25 +21,25 @@ from openerp import models, fields, api, _
|
|||||||
class GolemMember(models.Model):
|
class GolemMember(models.Model):
|
||||||
_inherit = 'golem.member'
|
_inherit = 'golem.member'
|
||||||
|
|
||||||
activity_session_registration_ids = fields.One2many(
|
activity_registration_ids = fields.One2many('golem.activity.registration',
|
||||||
'golem.activity.session.registration', 'member_id', 'Activities')
|
'member_id', 'Activities')
|
||||||
|
|
||||||
|
|
||||||
class GolemActivitySession(models.Model):
|
class GolemActivity(models.Model):
|
||||||
_inherit = 'golem.activity.session'
|
_inherit = 'golem.activity'
|
||||||
_sql_constraints = [('golem_activity_session_places_signed',
|
_sql_constraints = [('golem_activity_places_signed',
|
||||||
'CHECK (places >= 0)',
|
'CHECK (places >= 0)',
|
||||||
_('Number of places cannot be negative.'))]
|
_('Number of places cannot be negative.'))]
|
||||||
|
|
||||||
activity_session_registration_ids = fields.One2many(
|
activity_registration_ids = fields.One2many('golem.activity.registration',
|
||||||
'golem.activity.session.registration', 'session_id', 'Members')
|
'activity_id', 'Members')
|
||||||
places_used = fields.Integer('Places used', compute='_compute_places_used',
|
places_used = fields.Integer('Places used', compute='_compute_places_used',
|
||||||
store=True)
|
store=True)
|
||||||
|
|
||||||
@api.one
|
@api.one
|
||||||
@api.depends('activity_session_registration_ids')
|
@api.depends('activity_registration_ids')
|
||||||
def _compute_places_used(self):
|
def _compute_places_used(self):
|
||||||
self.places_used = len(self.activity_session_registration_ids)
|
self.places_used = len(self.activity_registration_ids)
|
||||||
|
|
||||||
places = fields.Integer('Places', default=20)
|
places = fields.Integer('Places', default=20)
|
||||||
places_remain = fields.Integer('Remaining places', store=True,
|
places_remain = fields.Integer('Remaining places', store=True,
|
||||||
@ -59,29 +59,29 @@ class GolemActivitySession(models.Model):
|
|||||||
raise models.ValidationError(emsg)
|
raise models.ValidationError(emsg)
|
||||||
|
|
||||||
|
|
||||||
class GolemActivitySessionRegistration(models.Model):
|
class GolemActivityRegistration(models.Model):
|
||||||
_name = 'golem.activity.session.registration'
|
_name = 'golem.activity.registration'
|
||||||
_description = 'GOLEM Activity Session Registration'
|
_description = 'GOLEM Activity Registration'
|
||||||
|
|
||||||
member_id = fields.Many2one('golem.member', string='Member', required=True,
|
member_id = fields.Many2one('golem.member', string='Member', required=True,
|
||||||
ondelete='cascade')
|
ondelete='cascade')
|
||||||
session_id = fields.Many2one('golem.activity.session', required=True,
|
activity_id = fields.Many2one('golem.activity', required=True,
|
||||||
string='Activity session', ondelete='cascade')
|
string='Activity', ondelete='cascade')
|
||||||
season_id = fields.Many2one(string='Season',
|
season_id = fields.Many2one(string='Season',
|
||||||
related='session_id.season_id')
|
related='activity_id.season_id')
|
||||||
is_current = fields.Boolean('Current season?',
|
is_current = fields.Boolean('Current season?',
|
||||||
related='session_id.is_current')
|
related='activity_id.is_current')
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('registration_uniq', 'UNIQUE (member_id, session_id)',
|
('registration_uniq', 'UNIQUE (member_id, activity_id)',
|
||||||
_('This member has already been registered for this session.'))]
|
_('This member has already been registered for this activity.'))]
|
||||||
|
|
||||||
@api.constrains('member_id', 'session_id')
|
@api.constrains('member_id', 'activity_id')
|
||||||
def _check_season_reliability(self):
|
def _check_season_reliability(self):
|
||||||
""" Forbid registration when member season if not coherent with
|
""" Forbid registration when member season if not coherent with
|
||||||
session season or are duplicates """
|
activity season or are duplicates """
|
||||||
for r in self:
|
for r in self:
|
||||||
if r.session_id.season_id not in r.member_id.season_ids:
|
if r.activity_id.season_id not in r.member_id.season_ids:
|
||||||
emsg = _('Subscription can not be executed : the targeted '
|
emsg = _('Subscription can not be executed : the targeted '
|
||||||
'member is not on the same season as the session.')
|
'member is not on the same season as the activity.')
|
||||||
raise models.ValidationError(emsg)
|
raise models.ValidationError(emsg)
|
@ -19,14 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<data>
|
<data>
|
||||||
<!-- Form -->
|
<!-- Form -->
|
||||||
<record id="registration_form" model="ir.ui.view">
|
<record id="registration_form" model="ir.ui.view">
|
||||||
<field name="name">Session registration form</field>
|
<field name="name">Activity registration form</field>
|
||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.registration</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<sheet>
|
<sheet>
|
||||||
<group string="Subscription">
|
<group string="Subscription">
|
||||||
<field name="member_id" invisible="1" />
|
<field name="member_id" invisible="1" />
|
||||||
<field name="session_id" />
|
<field name="activity_id" />
|
||||||
<field name="season_id" />
|
<field name="season_id" />
|
||||||
</group>
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
@ -37,26 +37,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
<!-- Tree -->
|
<!-- Tree -->
|
||||||
<record id="registration_tree" model="ir.ui.view">
|
<record id="registration_tree" model="ir.ui.view">
|
||||||
<field name="name">Session registration list</field>
|
<field name="name">Activity registration list</field>
|
||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.registration</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree create="true" edit="false" delete="false" editable="top">
|
<tree create="true" edit="false" delete="false" editable="top">
|
||||||
<field name="season_id" readonly="1" />
|
<field name="season_id" readonly="1" />
|
||||||
<field name="member_id" domain="[('is_current', '=', True)]" />
|
<field name="member_id" domain="[('is_current', '=', True)]" />
|
||||||
<field name="session_id" domain="[('is_current', '=', True)]" />
|
<field name="activity_id" domain="[('is_current', '=', True)]" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Search -->
|
<!-- Search -->
|
||||||
<record id="searches" model="ir.ui.view">
|
<record id="searches" model="ir.ui.view">
|
||||||
<field name="name">GOLEM Activity Session Registration searches</field>
|
<field name="name">GOLEM Activity Registration searches</field>
|
||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.registration</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search>
|
<search>
|
||||||
<field name="season_id" widget="many2one" />
|
<field name="season_id" widget="many2one" />
|
||||||
<field name="member_id" widget="many2one" />
|
<field name="member_id" widget="many2one" />
|
||||||
<field name="session_id" widget="many2one" />
|
<field name="activity_id" widget="many2one" />
|
||||||
<filter name="season_default" string="Default season"
|
<filter name="season_default" string="Default season"
|
||||||
domain="[('is_current', '=', True)]" />
|
domain="[('is_current', '=', True)]" />
|
||||||
</search>
|
</search>
|
||||||
@ -65,14 +65,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
<!-- Action -->
|
<!-- Action -->
|
||||||
<record id="registration_action_list" model="ir.actions.act_window">
|
<record id="registration_action_list" model="ir.actions.act_window">
|
||||||
<field name="name">GOLEM Activity Session Registration List</field>
|
<field name="name">GOLEM Activity Registration List</field>
|
||||||
<field name="res_model">golem.activity.session.registration</field>
|
<field name="res_model">golem.activity.registration</field>
|
||||||
<field name="view_mode">tree</field>
|
<field name="view_mode">tree</field>
|
||||||
<field name="context">{'search_default_season_default': True}</field>
|
<field name="context">{'search_default_season_default': True}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Menu -->
|
<!-- Menu -->
|
||||||
<menuitem id="registration_menu_list" name="Session registrations"
|
<menuitem id="registration_menu_list" name="Acitivity registrations"
|
||||||
parent="golem_activity.activity_menu" action="registration_action_list"
|
parent="golem_activity.activity_menu" action="registration_action_list"
|
||||||
groups="golem_base.group_golem_user"
|
groups="golem_base.group_golem_user"
|
||||||
sequence="20" />
|
sequence="20" />
|
@ -21,22 +21,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<!-- Form -->
|
<!-- Form -->
|
||||||
<record id="activity_form" model="ir.ui.view">
|
<record id="activity_form" model="ir.ui.view">
|
||||||
<field name="name">Activity Registrations and Places</field>
|
<field name="name">Activity Registrations and Places</field>
|
||||||
<field name="model">golem.activity.session</field>
|
<field name="model">golem.activity</field>
|
||||||
<field name="inherit_id" ref="golem_activity_session.view_form" />
|
<field name="inherit_id" ref="golem_activity.view_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="type_of" position="after">
|
<group name="places" position="inside">
|
||||||
<field name="places" />
|
<field name="places" />
|
||||||
</field>
|
</group>
|
||||||
<page string="Service" position="before">
|
<page string="Session" position="after">
|
||||||
<page string="Members">
|
<page string="Members">
|
||||||
<group>
|
<group>
|
||||||
<field name="places_remain" readonly="True" />
|
<field name="places_remain" readonly="True" />
|
||||||
<field name="activity_session_registration_ids"
|
<field name="activity_registration_ids"
|
||||||
context="{'default_session_id': active_id}">
|
context="{'default_activity_id': active_id}">
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
<field name="member_id"
|
<field name="member_id"
|
||||||
domain="[('season_ids', '=', season_id)]" />
|
domain="[('season_ids', '=', season_id)]" />
|
||||||
<field name="session_id" readonly="1" />
|
<field name="activity_id" readonly="1" />
|
||||||
<field name="season_id" readonly="1" />
|
<field name="season_id" readonly="1" />
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
@ -49,8 +49,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<!-- Tree -->
|
<!-- Tree -->
|
||||||
<record id="activity_tree" model="ir.ui.view">
|
<record id="activity_tree" model="ir.ui.view">
|
||||||
<field name="name">Activity Tree registrations additions</field>
|
<field name="name">Activity Tree registrations additions</field>
|
||||||
<field name="model">golem.activity.session</field>
|
<field name="model">golem.activity</field>
|
||||||
<field name="inherit_id" ref="golem_activity_session.session_tree" />
|
<field name="inherit_id" ref="golem_activity.view_tree" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="colors">red: places_remain == 0;orange: places_remain <= 4;</attribute>
|
<attribute name="colors">red: places_remain == 0;orange: places_remain <= 4;</attribute>
|
||||||
@ -65,11 +65,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<!-- Search -->
|
<!-- Search -->
|
||||||
<record id="activity_search" model="ir.ui.view">
|
<record id="activity_search" model="ir.ui.view">
|
||||||
<field name="name">Activity Search registrations additions</field>
|
<field name="name">Activity Search registrations additions</field>
|
||||||
<field name="model">golem.activity.session</field>
|
<field name="model">golem.activity</field>
|
||||||
<field name="inherit_id" ref="golem_activity_session.searches" />
|
<field name="inherit_id" ref="golem_activity.view_filter" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<filter name="season_default" position="after">
|
<filter name="season_default" position="after">
|
||||||
<filter name="full_session" string="Full"
|
<filter name="full_activity" string="Full"
|
||||||
domain="[('places_remain', '=', 0)]" />
|
domain="[('places_remain', '=', 0)]" />
|
||||||
</filter>
|
</filter>
|
||||||
</field>
|
</field>
|
@ -19,21 +19,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<data>
|
<data>
|
||||||
|
|
||||||
<!-- Form -->
|
<!-- Form -->
|
||||||
<record model="ir.ui.view" id="sessions_registration">
|
<record model="ir.ui.view" id="activities_registration">
|
||||||
<field name="name">Add sessions registrations to member form</field>
|
<field name="name">Add activities registrations to member form</field>
|
||||||
<field name="model">golem.member</field>
|
<field name="model">golem.member</field>
|
||||||
<field name="inherit_id" ref="golem_member.view_form" />
|
<field name="inherit_id" ref="golem_member.view_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<page name="other_page" position="before">
|
<page name="other_page" position="before">
|
||||||
<page name="sessions" string="Activities">
|
<page name="activities" string="Activities">
|
||||||
<p name="default_season_label">Default season activities</p>
|
<p name="default_season_label">Default season activities</p>
|
||||||
<field name="id" invisible="1" />
|
<field name="id" invisible="1" />
|
||||||
<group>
|
<group>
|
||||||
<field name="activity_session_registration_ids"
|
<field name="activity_registration_ids"
|
||||||
attrs="{'readonly': [('id', '=', False)]}"
|
attrs="{'readonly': [('id', '=', False)]}"
|
||||||
context="{'default_member_id': active_id}">
|
context="{'default_member_id': active_id}">
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
<field name="session_id"
|
<field name="activity_id"
|
||||||
domain="[('is_current', '=', True)]" />
|
domain="[('is_current', '=', True)]" />
|
||||||
<field name="season_id" readonly="1" />
|
<field name="season_id" readonly="1" />
|
||||||
<field name="member_id" readonly="1" />
|
<field name="member_id" readonly="1" />
|
Loading…
x
Reference in New Issue
Block a user