diff --git a/golem_activity_registration_payment_member_minor/__init__.py b/golem_activity_registration_payment_member_minor/__init__.py index 4cbbaff..21d8c2b 100644 --- a/golem_activity_registration_payment_member_minor/__init__.py +++ b/golem_activity_registration_payment_member_minor/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Fabien Bourgeois +# Copyright 2018-2019 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -15,4 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import wizard +from . import wizard, models diff --git a/golem_activity_registration_payment_member_minor/__manifest__.py b/golem_activity_registration_payment_member_minor/__manifest__.py index a177006..041cef7 100644 --- a/golem_activity_registration_payment_member_minor/__manifest__.py +++ b/golem_activity_registration_payment_member_minor/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Fabien Bourgeois +# Copyright 2018-2019 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,13 +18,14 @@ { 'name': 'GOLEM Activity Payment for Minors', 'summary': 'GOLEM Activity Registration Payment for Minors', - 'version': '10.0.0.1.1', + 'version': '10.0.0.2.0', 'category': 'GOLEM', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', 'application': False, 'installable': True, 'auto_install': True, - 'depends': ['golem_member_minor', 'golem_activity_registration_payment'], + 'depends': ['golem_member_minor', 'golem_activity_registration_payment', + 'golem_member_account'], 'data': ['views/golem_activity_registration_invoicing.xml'] } diff --git a/golem_activity_registration_payment_member_minor/models/__init__.py b/golem_activity_registration_payment_member_minor/models/__init__.py new file mode 100644 index 0000000..b8b1455 --- /dev/null +++ b/golem_activity_registration_payment_member_minor/models/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 Fabien Bourgeois +# +# 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 . + +from . import golem_member diff --git a/golem_activity_registration_payment_member_minor/models/golem_member.py b/golem_activity_registration_payment_member_minor/models/golem_member.py new file mode 100644 index 0000000..270a88b --- /dev/null +++ b/golem_activity_registration_payment_member_minor/models/golem_member.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 Fabien Bourgeois +# +# 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 . + +""" GOLEM Member adaptations """ + +from odoo import models, api + + +class GolemMember(models.Model): + """ GOLEM Member adaptations """ + _inherit = 'golem.member' + + @api.multi + def open_partner_invoices(self): + """ Overwrite open member invoices """ + self.ensure_one() + domain = ['|', + ('partner_id', '=', self.partner_id.id), + ('partner_ids', '=', self.partner_id.id)] + invoice_ids = self.env['account.invoice'].search(domain) + action = self.env.ref('account.action_invoice_tree1').read()[0] + action['context'] = {'type':'out_invoice', 'journal_type': 'sale', + 'default_partner_id': self[0].partner_id.id} + action['domain'] = [('id', 'in', invoice_ids.ids)] + return action + + @api.multi + def open_partner_payments(self): + """ Overwrite open member payments """ + self.ensure_one() + # Get related invoices + domain = ['|', + ('partner_id', '=', self.partner_id.id), + ('partner_ids', '=', self.partner_id.id)] + invoice_ids = self.env['account.invoice'].search(domain) + # Get related payments + domain = ['|', + ('partner_id', '=', self.partner_id.id), + ('invoice_ids', 'in', invoice_ids.ids)] + payment_ids = self.env['account.payment'].search(domain) + + action = self.env.ref('account.action_account_payments').read()[0] + action['context'] = {'default_payment_type': 'inbound', + 'default_partner_type': 'customer', + 'default_partner_id': self[0].partner_id.id} + action['domain'] = [('id', 'in', payment_ids.ids)] + return action