forked from Yaltik/golem
[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',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'depends': ['golem_activity_session_registration'],
|
||||
'depends': ['golem_activity_registration'],
|
||||
'data': ['views/golem_activity_session_registration_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')
|
||||
|
||||
@api.one
|
||||
@api.depends('activity_session_registration_ids')
|
||||
@api.depends('activity_registration_ids')
|
||||
def _compute_has_draft_registrations(self):
|
||||
""" 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':
|
||||
self.has_draft_registrations = True
|
||||
return
|
||||
@ -38,19 +38,19 @@ class GolemMember(models.Model):
|
||||
@api.one
|
||||
def do_validate_registrations(self):
|
||||
""" Validate all draft registrations """
|
||||
draft_registrations = self.activity_session_registration_ids.filtered(
|
||||
draft_registrations = self.activity_registration_ids.filtered(
|
||||
lambda r: r.state == 'draft')
|
||||
draft_registrations.write({'state': 'confirmed'})
|
||||
|
||||
@api.multi
|
||||
def write(self, values):
|
||||
""" Handle removed activities to be canceled """
|
||||
if 'activity_session_registration_ids' in values:
|
||||
rids = values['activity_session_registration_ids']
|
||||
if 'activity_registration_ids' in values:
|
||||
rids = values['activity_registration_ids']
|
||||
r_keep, r_removed = [], []
|
||||
for r in rids: # == 2 is removal case
|
||||
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:
|
||||
r = rObj.browse([rem[1]])
|
||||
# if already canceled, let it be removed, else cancel it
|
||||
@ -58,22 +58,22 @@ class GolemMember(models.Model):
|
||||
r.state = 'canceled'
|
||||
else:
|
||||
r_keep.append(rem)
|
||||
values['activity_session_registration_ids'] = r_keep
|
||||
values['activity_registration_ids'] = r_keep
|
||||
return super(GolemMember, self).write(values)
|
||||
|
||||
|
||||
class GolemActivitySession(models.Model):
|
||||
_inherit = 'golem.activity.session'
|
||||
class GolemActivity(models.Model):
|
||||
_inherit = 'golem.activity'
|
||||
|
||||
@api.one
|
||||
@api.depends('activity_session_registration_ids')
|
||||
@api.depends('activity_registration_ids')
|
||||
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'))
|
||||
|
||||
|
||||
class GolemActivitySessionRegistration(models.Model):
|
||||
_inherit = 'golem.activity.session.registration'
|
||||
class GolemActivityRegistration(models.Model):
|
||||
_inherit = 'golem.activity.registration'
|
||||
|
||||
state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'),
|
||||
('canceled', 'Canceled')], required=True,
|
||||
@ -87,8 +87,8 @@ class GolemActivitySessionRegistration(models.Model):
|
||||
@api.multi
|
||||
def write(self, values):
|
||||
""" Recomputes values linked to registrations when state change """
|
||||
res = super(GolemActivitySessionRegistration, self).write(values)
|
||||
res = super(GolemActivityRegistration, self).write(values)
|
||||
if values['state']:
|
||||
for r in self:
|
||||
r.session_id._compute_places_used()
|
||||
r.activity_id._compute_places_used()
|
||||
return res
|
@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<!-- Tree -->
|
||||
<record id="state_tree" model="ir.ui.view">
|
||||
<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"
|
||||
ref="golem_activity_session_registration.registration_tree" />
|
||||
ref="golem_activity_registration.registration_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<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">
|
||||
<field name="state" invisible="1" />
|
||||
</tree>
|
||||
<field name="session_id" position="after">
|
||||
<field name="activity_id" position="after">
|
||||
<field name="invoice_id" readonly="1" />
|
||||
<field name="invoice_line_id" readonly="1" />
|
||||
</field>
|
||||
@ -41,11 +41,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<!-- Search -->
|
||||
<record id="state_searches" model="ir.ui.view">
|
||||
<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"
|
||||
ref="golem_activity_session_registration.searches" />
|
||||
ref="golem_activity_registration.searches" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="session_id" position="after">
|
||||
<field name="activity_id" position="after">
|
||||
<field name="invoice_id" widget="many2one" />
|
||||
</field>
|
||||
</field>
|
@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<!-- Form -->
|
||||
<record id="state_activity_form" model="ir.ui.view">
|
||||
<field name="name">Activity Registrations States</field>
|
||||
<field name="model">golem.activity.session</field>
|
||||
<field name="model">golem.activity</field>
|
||||
<field name="inherit_id"
|
||||
ref="golem_activity_session_registration.activity_form" />
|
||||
ref="golem_activity_registration.activity_form" />
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<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 -->
|
||||
<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="inherit_id"
|
||||
ref="golem_activity_session_registration.sessions_registration" />
|
||||
ref="golem_activity_registration.activities_registration" />
|
||||
<field name="arch" type="xml">
|
||||
<p name="default_season_label" position="after">
|
||||
<p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}">
|
Loading…
Reference in New Issue
Block a user