[ADD]GOLEM Family Membership : multiple enhancements
* Ability to choose 1:n members for each subscription ; * Do not invoice more than 1 person ; * Keep subscription tracking info on family form ; * Allow subscription cancel.
This commit is contained in:
parent
d6e3da556a
commit
09017b13e9
@ -27,6 +27,7 @@
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'depends': ['golem_family', 'membership'],
|
||||
'data': ['views/golem_family_views.xml',
|
||||
'data': ['views/membership_views.xml',
|
||||
'views/golem_family_views.xml',
|
||||
'wizard/golem_membership_invoice_views.xml']
|
||||
}
|
||||
|
@ -16,4 +16,4 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from . import golem_family
|
||||
from . import product_template, membership, golem_family
|
||||
|
@ -18,13 +18,16 @@
|
||||
|
||||
""" GOLEM Families Adaptations"""
|
||||
|
||||
from odoo import models, api, _
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class GolemFamily(models.Model):
|
||||
""" GOLEM Family Adaptations """
|
||||
_inherit = 'golem.family'
|
||||
|
||||
member_line_ids = fields.One2many('membership.membership_line',
|
||||
'family_id', string='Membership lines')
|
||||
|
||||
@api.multi
|
||||
def family_membership(self):
|
||||
""" Wizard call for family membership """
|
||||
|
29
golem_family_membership/models/membership.py
Normal file
29
golem_family_membership/models/membership.py
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
|
||||
# Copyright 2018 Fabien Bourgeois <fabien@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
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" GOLEM Families Adaptations"""
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class MembershipLine(models.Model):
|
||||
""" Membership Line Adaptations """
|
||||
_inherit = 'membership.membership_line'
|
||||
|
||||
family_id = fields.Many2one('golem.family', string='Family',
|
||||
ondelete='cascade', index=True)
|
27
golem_family_membership/models/product_template.py
Normal file
27
golem_family_membership/models/product_template.py
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 Fabien Bourgeois <fabien@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
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" Product adaptations """
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
""" Product Template adaptations """
|
||||
_inherit = 'product.template'
|
||||
|
||||
family_membership = fields.Boolean(default=False)
|
@ -20,22 +20,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- Forms -->
|
||||
<record model="ir.ui.view" id="golem_family_form_inherit_golem_family">
|
||||
<field name="name">Golem Family form adaptations</field>
|
||||
<field name="model">golem.family</field>
|
||||
<field name="inherit_id" ref="golem_family.golem_family_form" />
|
||||
<field name="arch" type="xml">
|
||||
<sheet position="before">
|
||||
<header>
|
||||
<page name="members" position="after">
|
||||
<page name="subscriptions" string="Subscriptions">
|
||||
<field name="id" invisible="1" />
|
||||
<button name="family_membership" type="object"
|
||||
string="Family membership" class="oe_highlight"
|
||||
string="Add a new family membership" class="oe_link"
|
||||
attrs="{'invisible': ['|', ('id', '=', False), ('member_ids', '=', [])]}" />
|
||||
<field name="id" invisible="1"/>
|
||||
<field name="member_ids" invisible="1"/>
|
||||
</header>
|
||||
</sheet>
|
||||
<field name="member_line_ids" nolabel="1" readonly="1">
|
||||
<tree string="Memberships">
|
||||
<field name="date"/>
|
||||
<field name="membership_id"/>
|
||||
<field name="partner" />
|
||||
<field name="member_price"/>
|
||||
<field name="account_invoice_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
55
golem_family_membership/views/membership_views.xml
Normal file
55
golem_family_membership/views/membership_views.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 Fabien Bourgeois <fabien@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 published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- Forms -->
|
||||
<record id="membership_products_view_form_inherit_golem_family_membership"
|
||||
model="ir.ui.view">
|
||||
<field name="name">Membership Product Form adaptations</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="membership.membership_products_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="default_code" position="before">
|
||||
<field name="family_membership" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Searches -->
|
||||
<record id="membership_product_search_form_view_inherit_golem_family_membership"
|
||||
model="ir.ui.view">
|
||||
<field name="name">Membership Product Search adaptations</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="membership.membership_product_search_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after">
|
||||
<field name="membership_season_id" />
|
||||
</field>
|
||||
<xpath expr="//group/filter[1]" position="after">
|
||||
<separator />
|
||||
<filter name="family_membership_0" string="Classic"
|
||||
domain="[('family_membership', '=', False)]" />
|
||||
<filter name="family_membership_1" string="Family"
|
||||
domain="[('family_membership', '=', True)]" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
@ -24,15 +24,29 @@ class GolemMembershipInvoice(models.TransientModel):
|
||||
""" GOLEM Membership Invoice adaptations """
|
||||
_inherit = 'golem.membership.invoice'
|
||||
|
||||
family_id = fields.Many2one('golem.family', required=True)
|
||||
members_ids = fields.Many2many('res.partner')
|
||||
on_the_name_of = fields.Many2one('res.partner', domain="[('id', '=', members_ids[0][2])]")
|
||||
family_id = fields.Many2one('golem.family', string='Family',
|
||||
required=True, ondelete='cascade')
|
||||
member_ids = fields.Many2many('res.partner', string='Concerned members')
|
||||
on_the_name_of = fields.Many2one('res.partner', ondelete='cascade',
|
||||
required=True)
|
||||
|
||||
@api.onchange('family_id')
|
||||
def onchange_family(self):
|
||||
""" Fill members_ids """
|
||||
""" Fill member_ids """
|
||||
for record in self:
|
||||
record.members_ids = [(6, False, record.family_id.members_ids.ids)]
|
||||
if record.family_id and record.family_id.member_ids:
|
||||
record.member_ids = [(6, False,
|
||||
record.family_id.member_ids.ids)]
|
||||
|
||||
@api.onchange('member_ids')
|
||||
def onchange_members(self):
|
||||
""" On change members : custom domain for on the name of """
|
||||
record = self[0]
|
||||
if record.member_ids:
|
||||
return {
|
||||
'domain': {'on_the_name_of': [('id', 'in', record.member_ids.ids)]}
|
||||
}
|
||||
return {'domain': {'on_the_name_of': []}}
|
||||
|
||||
@api.multi
|
||||
def membership_family_invoice(self):
|
||||
@ -42,13 +56,13 @@ class GolemMembershipInvoice(models.TransientModel):
|
||||
datas = {'membership_product_id': record.product_id.id,
|
||||
'amount': record.member_price}
|
||||
invoice_list = record.on_the_name_of.create_membership_invoice(datas=datas)
|
||||
datas = {'membership_product_id': record.product_id.id,
|
||||
'amount': 0.0}
|
||||
gen = (member for member in record.members_ids if member != record.on_the_name_of)
|
||||
for member in gen:
|
||||
id_membership = member.create_membership_invoice(datas=datas)
|
||||
self.env['account.invoice'].browse(id_membership).action_invoice_open()
|
||||
invoice_list += id_membership
|
||||
# Link membership lines to family and targetted members
|
||||
membership_line = record.on_the_name_of.member_lines[0] # Last one
|
||||
membership_line.family_id = record.family_id
|
||||
# Add membership lines for other family members
|
||||
for member in record.member_ids:
|
||||
if member != record.on_the_name_of:
|
||||
membership_line.copy({'partner': member.id})
|
||||
|
||||
search_view_id = self.env.ref('account.view_account_invoice_filter')
|
||||
form_view_id = self.env.ref('account.invoice_form')
|
||||
|
@ -28,9 +28,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<form string="Membership Invoice">
|
||||
<group>
|
||||
<field name="family_id" readonly="1" />
|
||||
<field name="members_ids" widget="many2many_tags" />
|
||||
<field name="on_the_name_of" options="{'no_create': True}" />
|
||||
<field name="product_id" domain="[('membership','=',True)]"
|
||||
<field name="member_ids" widget="many2many_tags"
|
||||
options="{'no_create': True}" />
|
||||
<field name="on_the_name_of" options="{'no_create': True}"
|
||||
attrs="{'readonly': [('member_ids', '=', [])]}" />
|
||||
<field name="product_id" domain="[('family_membership','=',True)]"
|
||||
widget="selection" />
|
||||
<field name="member_price" />
|
||||
</group>
|
||||
|
Loading…
Reference in New Issue
Block a user