[REF][IMP]GOLEM Activity Registration Payment free activities
This commit is contained in:
parent
08927bba53
commit
223bc581fd
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2018 Youssef El Ouahby <youssef@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
|
||||
@ -19,7 +20,7 @@
|
||||
'name': 'GOLEM Activity Member Registration Payments',
|
||||
'summary': 'GOLEM Activities Member Registration Payments',
|
||||
'description': 'GOLEM Activities Member Registration Payments',
|
||||
'version': '10.0.0.3.6',
|
||||
'version': '10.0.0.4.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -18,10 +18,17 @@
|
||||
|
||||
""" GOLEM Activity adaptations """
|
||||
|
||||
from odoo import models, fields
|
||||
from odoo import models, fields, api
|
||||
|
||||
class GolemActivity(models.Model):
|
||||
""" GOLEM Activity adaptations """
|
||||
_inherit = 'golem.activity'
|
||||
|
||||
free_activity = fields.Boolean(required=True)
|
||||
free_activity = fields.Boolean(default=False)
|
||||
|
||||
@api.onchange('free_activity')
|
||||
def onchange_free_activity(self):
|
||||
""" If free activity, price should be 0.0 """
|
||||
for activity in self:
|
||||
if activity.free_activity:
|
||||
activity.list_price = 0.0
|
||||
|
@ -31,3 +31,4 @@ class GolemActivityRegistration(models.Model):
|
||||
invoice_id = fields.Many2one(related='invoice_line_id.invoice_id')
|
||||
invoice_state = fields.Selection(related='invoice_line_id.invoice_id.state',
|
||||
store=True)
|
||||
free_activity = fields.Boolean(related='activity_id.free_activity')
|
||||
|
@ -35,9 +35,9 @@ class GolemMember(models.Model):
|
||||
regis = member.activity_registration_ids
|
||||
regis = regis.filtered(
|
||||
lambda r: (r.state == 'confirmed' and
|
||||
not r.activity_id.free_activity and
|
||||
(not r.invoice_line_id or
|
||||
r.invoice_line_id.invoice_id.state == 'cancel') and
|
||||
not r.activity_id.free_activity)
|
||||
r.invoice_line_id.invoice_id.state == 'cancel'))
|
||||
)
|
||||
member.has_invoicable_registrations = bool(len(regis))
|
||||
|
||||
@ -53,10 +53,10 @@ class GolemMember(models.Model):
|
||||
self.ensure_one()
|
||||
member = self[0]
|
||||
registrations = member.activity_registration_ids.filtered(
|
||||
lambda r: r.state == 'confirmed' and
|
||||
(not r.invoice_line_id or
|
||||
r.invoice_line_id.invoice_id.state == 'cancel') and
|
||||
not r.activity_id.free_activity
|
||||
lambda r: (r.state == 'confirmed' and
|
||||
not r.activity_id.free_activity and
|
||||
(not r.invoice_line_id or
|
||||
r.invoice_line_id.invoice_id.state == 'cancel'))
|
||||
)
|
||||
if registrations:
|
||||
invoicing = self.env['golem.activity.registration.invoicing'].create({
|
||||
|
@ -45,6 +45,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="inherit_id"
|
||||
ref="golem_activity_registration_state.golem_activity_registration_tree_inherit_state" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="activity_price" position="before">
|
||||
<field name="free_activity" readonly="1" />
|
||||
</field>
|
||||
<field name="activity_price" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('free_activity', '=', True)]}</attribute>
|
||||
</field>
|
||||
<field name="state" position="after">
|
||||
<field name="invoice_line_id" invisible="1" />
|
||||
<field name="invoice_state" string="Invoice state" />
|
||||
|
@ -22,24 +22,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<!-- Forms -->
|
||||
<record id="golem_activity_form_inherit_activity_registration_payment"
|
||||
model="ir.ui.view">
|
||||
<field name="name">Golem activity form activity registration payment adaptations</field>
|
||||
<field name="name">Golem activity form adaptations</field>
|
||||
<field name="model">golem.activity</field>
|
||||
<field name="inherit_id" ref="golem_activity.golem_activity_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="list_price" position="after">
|
||||
<field name='free_activity'/>
|
||||
<field name="list_price" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('free_activity', '=', True)]}</attribute>
|
||||
</field>
|
||||
<field name="list_price" position="before">
|
||||
<field name='free_activity' />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search -->
|
||||
<record id="golem_activity_search_inherit_activity_registration_payment"
|
||||
model="ir.ui.view">
|
||||
<field name="name">Golem Activity Search activity registration payment adaptations</field>
|
||||
<field name="name">Golem Activity Search adaptations</field>
|
||||
<field name="model">golem.activity</field>
|
||||
<field name="inherit_id" ref="golem_activity.golem_activity_search" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="season_default" position="after">
|
||||
<filter name="free_activity" string="Free activity" domain="[('free_activity', '=', True)]"/>
|
||||
<filter name="free_activity" string="Free activity"
|
||||
domain="[('free_activity', '=', True)]" />
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
Loading…
Reference in New Issue
Block a user