forked from Yaltik/golem
[REF]GOLEM Family Membership : small refactorings / quality
This commit is contained in:
parent
3676634790
commit
390bcb18f1
@ -17,16 +17,16 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
{
|
||||
'name': 'GOLEM families membership',
|
||||
'summary': 'GOLEM Families membership ',
|
||||
'description': 'GOLEM Families Membership',
|
||||
'version': '10.0.0.0.0',
|
||||
'name': 'GOLEM Family Memberships',
|
||||
'summary': 'GOLEM Family Membership Management',
|
||||
'description': 'GOLEM Family Membership Management',
|
||||
'version': '10.0.0.1.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois, Youssef ELOUAHBY',
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'depends': ['golem_family'],
|
||||
'depends': ['golem_family', 'membership'],
|
||||
'data': ['views/golem_family_views.xml',
|
||||
'wizard/golem_membership_invoice_views.xml']
|
||||
}
|
||||
|
@ -18,7 +18,8 @@
|
||||
|
||||
""" GOLEM Families Adaptations"""
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo import models, api, _
|
||||
|
||||
|
||||
class GolemFamily(models.Model):
|
||||
""" GOLEM Family Adaptations """
|
||||
@ -28,12 +29,12 @@ class GolemFamily(models.Model):
|
||||
def family_membership(self):
|
||||
""" Wizard call for family membership """
|
||||
self.ensure_one()
|
||||
family_id = self[0]
|
||||
family = self[0]
|
||||
return {
|
||||
'name' : _('Please fill the family membership form'),
|
||||
'type' : 'ir.actions.act_window',
|
||||
'res_model' : 'golem.membership.invoice',
|
||||
'context': {'default_family_id': family_id.id},
|
||||
'context': {'default_family_id': family.id},
|
||||
'view_mode': 'form',
|
||||
'target': 'new'
|
||||
}
|
||||
|
@ -24,27 +24,26 @@ class GolemMembershipInvoice(models.TransientModel):
|
||||
""" GOLEM Membership Invoice adaptations """
|
||||
_inherit = 'golem.membership.invoice'
|
||||
|
||||
family_id = fields.Many2one('golem.family')
|
||||
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])]")
|
||||
|
||||
@api.onchange('family_id')
|
||||
def onchange_family_id(self):
|
||||
""" fill members_ids """
|
||||
def onchange_family(self):
|
||||
""" Fill members_ids """
|
||||
for record in self:
|
||||
for member in record.family_id.member_ids:
|
||||
record.members_ids += member
|
||||
record.members_ids = [(6, False, record.family_id.members_ids.ids)]
|
||||
|
||||
@api.multi
|
||||
def membership_family_invoice(self):
|
||||
""" Create family membership """
|
||||
self.ensure_one()
|
||||
record = self[0]
|
||||
datas = {'membership_product_id': self.product_id.id,
|
||||
'amount': self.member_price}
|
||||
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': self.product_id.id,
|
||||
'amount': 0}
|
||||
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)
|
||||
|
@ -16,17 +16,19 @@ 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 -->
|
||||
|
||||
<!-- Forms -->
|
||||
<record id="golem_membership_family_invoice_form" model="ir.ui.view">
|
||||
<field name="name">membership.family.invoice.view.form</field>
|
||||
<field name="name">GOLEM Membership Family Invoice Form</field>
|
||||
<field name="model">golem.membership.invoice</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Membership Invoice">
|
||||
<group>
|
||||
<field name="family_id" readonly="1"/>
|
||||
<field name="members_ids" invisible="1" widget="many2many_tags"/>
|
||||
<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)]"
|
||||
widget="selection" />
|
||||
@ -34,12 +36,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Invoice Membership" name="membership_family_invoice"
|
||||
type="object" class="oe_highlight" />
|
||||
type="object" class="oe_highlight" />
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user