[IMP]GOLEM Activity Session Registration state validation from draft to confirmed
This commit is contained in:
parent
eb062cae35
commit
ebe3c9bde5
@ -23,6 +23,26 @@ class GolemMember(models.Model):
|
|||||||
|
|
||||||
activity_session_registration_ids = fields.One2many(
|
activity_session_registration_ids = fields.One2many(
|
||||||
'golem.activity.session.registration', 'member_id', 'Activities')
|
'golem.activity.session.registration', 'member_id', 'Activities')
|
||||||
|
has_draft_registrations = fields.Boolean(
|
||||||
|
'Has draft registrations ?',
|
||||||
|
compute='_compute_has_draft_registrations')
|
||||||
|
|
||||||
|
@api.one
|
||||||
|
@api.depends('activity_session_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:
|
||||||
|
if r.state == 'draft':
|
||||||
|
self.has_draft_registrations = True
|
||||||
|
return
|
||||||
|
self.has_draft_registrations = False
|
||||||
|
|
||||||
|
@api.one
|
||||||
|
def do_validate_registrations(self):
|
||||||
|
""" Validate all draft registrations """
|
||||||
|
draft_registrations = self.activity_session_registration_ids.filtered(
|
||||||
|
lambda r: r.state == 'draft')
|
||||||
|
draft_registrations.write({'state': 'confirmed'})
|
||||||
|
|
||||||
|
|
||||||
class GolemActivitySession(models.Model):
|
class GolemActivitySession(models.Model):
|
||||||
|
@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.session.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"
|
||||||
colors="red: state == 'canceled';grey: state == 'draft';">
|
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
||||||
<field name="state" invisible="1" />
|
<field name="state" invisible="1" />
|
||||||
<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)]" />
|
||||||
|
@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="activity_session_registration_ids"
|
<field name="activity_session_registration_ids"
|
||||||
context="{'default_session_id': active_id}">
|
context="{'default_session_id': active_id}">
|
||||||
<tree editable="top"
|
<tree editable="top"
|
||||||
colors="red: state == 'canceled';grey: state == 'draft';">
|
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
||||||
<field name="state" invisible="1" />
|
<field name="state" invisible="1" />
|
||||||
<field name="member_id"
|
<field name="member_id"
|
||||||
domain="[('season_ids', '=', season_id)]" />
|
domain="[('season_ids', '=', season_id)]" />
|
||||||
|
@ -27,10 +27,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<page name="other_page" position="before">
|
<page name="other_page" position="before">
|
||||||
<page name="sessions" string="Activities">
|
<page name="sessions" string="Activities">
|
||||||
<p>Default season activities</p>
|
<p>Default season activities</p>
|
||||||
|
<p>
|
||||||
|
<field name="has_draft_registrations" invisible="1" />
|
||||||
|
<button name="do_validate_registrations" type="object"
|
||||||
|
string="Validate all draft registrations"
|
||||||
|
class="oe_highlight"
|
||||||
|
help="If you validate draft registration, they will be seen as confirmed. Then, an invoice will be created for the current member."
|
||||||
|
attrs="{'invisible': [('has_draft_registrations', '=', False)]}" />
|
||||||
|
<!-- TODO : one by one cancelation -->
|
||||||
|
<!-- TODO : do not allow removal if confirmed -->
|
||||||
|
</p>
|
||||||
<field name="activity_session_registration_ids"
|
<field name="activity_session_registration_ids"
|
||||||
context="{'default_member_id': active_id}">
|
context="{'default_member_id': active_id}">
|
||||||
<tree editable="top"
|
<tree editable="top"
|
||||||
colors="red: state == 'canceled';grey: state == 'draft';">
|
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
||||||
<field name="state" invisible="1" />
|
<field name="state" invisible="1" />
|
||||||
<field name="session_id"
|
<field name="session_id"
|
||||||
domain="[('is_current', '=', True)]" />
|
domain="[('is_current', '=', True)]" />
|
||||||
|
Loading…
Reference in New Issue
Block a user