[REF][IMP]GOLEM Activity Registration Payment free activities

This commit is contained in:
Fabien BOURGEOIS 2018-09-26 11:41:38 +02:00
parent 08927bba53
commit 223bc581fd
6 changed files with 34 additions and 14 deletions

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com> # 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 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -19,7 +20,7 @@
'name': 'GOLEM Activity Member Registration Payments', 'name': 'GOLEM Activity Member Registration Payments',
'summary': 'GOLEM Activities Member Registration Payments', 'summary': 'GOLEM Activities Member Registration Payments',
'description': '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', 'category': 'GOLEM',
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -18,10 +18,17 @@
""" GOLEM Activity adaptations """ """ GOLEM Activity adaptations """
from odoo import models, fields from odoo import models, fields, api
class GolemActivity(models.Model): class GolemActivity(models.Model):
""" GOLEM Activity adaptations """ """ GOLEM Activity adaptations """
_inherit = 'golem.activity' _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

View File

@ -31,3 +31,4 @@ class GolemActivityRegistration(models.Model):
invoice_id = fields.Many2one(related='invoice_line_id.invoice_id') invoice_id = fields.Many2one(related='invoice_line_id.invoice_id')
invoice_state = fields.Selection(related='invoice_line_id.invoice_id.state', invoice_state = fields.Selection(related='invoice_line_id.invoice_id.state',
store=True) store=True)
free_activity = fields.Boolean(related='activity_id.free_activity')

View File

@ -35,9 +35,9 @@ class GolemMember(models.Model):
regis = member.activity_registration_ids regis = member.activity_registration_ids
regis = regis.filtered( regis = regis.filtered(
lambda r: (r.state == 'confirmed' and lambda r: (r.state == 'confirmed' and
not r.activity_id.free_activity and
(not r.invoice_line_id or (not r.invoice_line_id or
r.invoice_line_id.invoice_id.state == 'cancel') and r.invoice_line_id.invoice_id.state == 'cancel'))
not r.activity_id.free_activity)
) )
member.has_invoicable_registrations = bool(len(regis)) member.has_invoicable_registrations = bool(len(regis))
@ -53,10 +53,10 @@ class GolemMember(models.Model):
self.ensure_one() self.ensure_one()
member = self[0] member = self[0]
registrations = member.activity_registration_ids.filtered( registrations = member.activity_registration_ids.filtered(
lambda r: r.state == 'confirmed' and lambda r: (r.state == 'confirmed' and
(not r.invoice_line_id or not r.activity_id.free_activity and
r.invoice_line_id.invoice_id.state == 'cancel') and (not r.invoice_line_id or
not r.activity_id.free_activity r.invoice_line_id.invoice_id.state == 'cancel'))
) )
if registrations: if registrations:
invoicing = self.env['golem.activity.registration.invoicing'].create({ invoicing = self.env['golem.activity.registration.invoicing'].create({

View File

@ -45,6 +45,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="inherit_id" <field name="inherit_id"
ref="golem_activity_registration_state.golem_activity_registration_tree_inherit_state" /> ref="golem_activity_registration_state.golem_activity_registration_tree_inherit_state" />
<field name="arch" type="xml"> <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="state" position="after">
<field name="invoice_line_id" invisible="1" /> <field name="invoice_line_id" invisible="1" />
<field name="invoice_state" string="Invoice state" /> <field name="invoice_state" string="Invoice state" />

View File

@ -22,24 +22,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<!-- Forms --> <!-- Forms -->
<record id="golem_activity_form_inherit_activity_registration_payment" <record id="golem_activity_form_inherit_activity_registration_payment"
model="ir.ui.view"> 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="model">golem.activity</field>
<field name="inherit_id" ref="golem_activity.golem_activity_form" /> <field name="inherit_id" ref="golem_activity.golem_activity_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="list_price" position="after"> <field name="list_price" position="attributes">
<field name='free_activity'/> <attribute name="attrs">{'invisible': [('free_activity', '=', True)]}</attribute>
</field>
<field name="list_price" position="before">
<field name='free_activity' />
</field> </field>
</field> </field>
</record> </record>
<!-- Search --> <!-- Search -->
<record id="golem_activity_search_inherit_activity_registration_payment" <record id="golem_activity_search_inherit_activity_registration_payment"
model="ir.ui.view"> 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="model">golem.activity</field>
<field name="inherit_id" ref="golem_activity.golem_activity_search" /> <field name="inherit_id" ref="golem_activity.golem_activity_search" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<filter name="season_default" position="after"> <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> </filter>
</field> </field>
</record> </record>