[MIG]GOLEM Activity Session Registration State migration withtout sessions...
This commit is contained in:
parent
90967da7de
commit
986c445080
@ -26,7 +26,7 @@
|
|||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'application': False,
|
'application': False,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'depends': ['golem_activity_session_registration'],
|
'depends': ['golem_activity_registration'],
|
||||||
'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']
|
||||||
}
|
}
|
@ -26,10 +26,10 @@ class GolemMember(models.Model):
|
|||||||
compute='_compute_has_draft_registrations')
|
compute='_compute_has_draft_registrations')
|
||||||
|
|
||||||
@api.one
|
@api.one
|
||||||
@api.depends('activity_session_registration_ids')
|
@api.depends('activity_registration_ids')
|
||||||
def _compute_has_draft_registrations(self):
|
def _compute_has_draft_registrations(self):
|
||||||
""" Check if there are draft states in member activities """
|
""" Check if there are draft states in member activities """
|
||||||
for r in self.activity_session_registration_ids:
|
for r in self.activity_registration_ids:
|
||||||
if r.state == 'draft':
|
if r.state == 'draft':
|
||||||
self.has_draft_registrations = True
|
self.has_draft_registrations = True
|
||||||
return
|
return
|
||||||
@ -38,19 +38,19 @@ class GolemMember(models.Model):
|
|||||||
@api.one
|
@api.one
|
||||||
def do_validate_registrations(self):
|
def do_validate_registrations(self):
|
||||||
""" Validate all draft registrations """
|
""" Validate all draft registrations """
|
||||||
draft_registrations = self.activity_session_registration_ids.filtered(
|
draft_registrations = self.activity_registration_ids.filtered(
|
||||||
lambda r: r.state == 'draft')
|
lambda r: r.state == 'draft')
|
||||||
draft_registrations.write({'state': 'confirmed'})
|
draft_registrations.write({'state': 'confirmed'})
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, values):
|
def write(self, values):
|
||||||
""" Handle removed activities to be canceled """
|
""" Handle removed activities to be canceled """
|
||||||
if 'activity_session_registration_ids' in values:
|
if 'activity_registration_ids' in values:
|
||||||
rids = values['activity_session_registration_ids']
|
rids = values['activity_registration_ids']
|
||||||
r_keep, r_removed = [], []
|
r_keep, r_removed = [], []
|
||||||
for r in rids: # == 2 is removal case
|
for r in rids: # == 2 is removal case
|
||||||
r_removed.append(r) if r[0] == 2 else r_keep.append(r)
|
r_removed.append(r) if r[0] == 2 else r_keep.append(r)
|
||||||
rObj = self.env['golem.activity.session.registration']
|
rObj = self.env['golem.activity.registration']
|
||||||
for rem in r_removed:
|
for rem in r_removed:
|
||||||
r = rObj.browse([rem[1]])
|
r = rObj.browse([rem[1]])
|
||||||
# if already canceled, let it be removed, else cancel it
|
# if already canceled, let it be removed, else cancel it
|
||||||
@ -58,22 +58,22 @@ class GolemMember(models.Model):
|
|||||||
r.state = 'canceled'
|
r.state = 'canceled'
|
||||||
else:
|
else:
|
||||||
r_keep.append(rem)
|
r_keep.append(rem)
|
||||||
values['activity_session_registration_ids'] = r_keep
|
values['activity_registration_ids'] = r_keep
|
||||||
return super(GolemMember, self).write(values)
|
return super(GolemMember, self).write(values)
|
||||||
|
|
||||||
|
|
||||||
class GolemActivitySession(models.Model):
|
class GolemActivity(models.Model):
|
||||||
_inherit = 'golem.activity.session'
|
_inherit = 'golem.activity'
|
||||||
|
|
||||||
@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):
|
||||||
rids = self.activity_session_registration_ids
|
rids = self.activity_registration_ids
|
||||||
self.places_used = len(rids.filtered(lambda r: r.state == 'confirmed'))
|
self.places_used = len(rids.filtered(lambda r: r.state == 'confirmed'))
|
||||||
|
|
||||||
|
|
||||||
class GolemActivitySessionRegistration(models.Model):
|
class GolemActivityRegistration(models.Model):
|
||||||
_inherit = 'golem.activity.session.registration'
|
_inherit = 'golem.activity.registration'
|
||||||
|
|
||||||
state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'),
|
state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'),
|
||||||
('canceled', 'Canceled')], required=True,
|
('canceled', 'Canceled')], required=True,
|
||||||
@ -87,8 +87,8 @@ class GolemActivitySessionRegistration(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def write(self, values):
|
def write(self, values):
|
||||||
""" Recomputes values linked to registrations when state change """
|
""" Recomputes values linked to registrations when state change """
|
||||||
res = super(GolemActivitySessionRegistration, self).write(values)
|
res = super(GolemActivityRegistration, self).write(values)
|
||||||
if values['state']:
|
if values['state']:
|
||||||
for r in self:
|
for r in self:
|
||||||
r.session_id._compute_places_used()
|
r.activity_id._compute_places_used()
|
||||||
return res
|
return res
|
@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<!-- Tree -->
|
<!-- Tree -->
|
||||||
<record id="state_tree" model="ir.ui.view">
|
<record id="state_tree" model="ir.ui.view">
|
||||||
<field name="name">Session registration list</field>
|
<field name="name">Session registration list</field>
|
||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.registration</field>
|
||||||
<field name="inherit_id"
|
<field name="inherit_id"
|
||||||
ref="golem_activity_session_registration.registration_tree" />
|
ref="golem_activity_registration.registration_tree" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute>
|
<attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute>
|
||||||
@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<tree position="inside">
|
<tree position="inside">
|
||||||
<field name="state" invisible="1" />
|
<field name="state" invisible="1" />
|
||||||
</tree>
|
</tree>
|
||||||
<field name="session_id" position="after">
|
<field name="activity_id" position="after">
|
||||||
<field name="invoice_id" readonly="1" />
|
<field name="invoice_id" readonly="1" />
|
||||||
<field name="invoice_line_id" readonly="1" />
|
<field name="invoice_line_id" readonly="1" />
|
||||||
</field>
|
</field>
|
||||||
@ -41,11 +41,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<!-- Search -->
|
<!-- Search -->
|
||||||
<record id="state_searches" model="ir.ui.view">
|
<record id="state_searches" model="ir.ui.view">
|
||||||
<field name="name">Registration state specific searches</field>
|
<field name="name">Registration state specific searches</field>
|
||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.registration</field>
|
||||||
<field name="inherit_id"
|
<field name="inherit_id"
|
||||||
ref="golem_activity_session_registration.searches" />
|
ref="golem_activity_registration.searches" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="session_id" position="after">
|
<field name="activity_id" position="after">
|
||||||
<field name="invoice_id" widget="many2one" />
|
<field name="invoice_id" widget="many2one" />
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<!-- Form -->
|
<!-- Form -->
|
||||||
<record id="state_activity_form" model="ir.ui.view">
|
<record id="state_activity_form" model="ir.ui.view">
|
||||||
<field name="name">Activity Registrations States</field>
|
<field name="name">Activity Registrations States</field>
|
||||||
<field name="model">golem.activity.session</field>
|
<field name="model">golem.activity</field>
|
||||||
<field name="inherit_id"
|
<field name="inherit_id"
|
||||||
ref="golem_activity_session_registration.activity_form" />
|
ref="golem_activity_registration.activity_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute>
|
<attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute>
|
@ -20,10 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
<!-- Form -->
|
<!-- Form -->
|
||||||
<record model="ir.ui.view" id="registration_state">
|
<record model="ir.ui.view" id="registration_state">
|
||||||
<field name="name">Add state for sessions registrations</field>
|
<field name="name">Add state for registrations</field>
|
||||||
<field name="model">golem.member</field>
|
<field name="model">golem.member</field>
|
||||||
<field name="inherit_id"
|
<field name="inherit_id"
|
||||||
ref="golem_activity_session_registration.sessions_registration" />
|
ref="golem_activity_registration.activities_registration" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<p name="default_season_label" position="after">
|
<p name="default_season_label" position="after">
|
||||||
<p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}">
|
<p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}">
|
Loading…
Reference in New Issue
Block a user