# -*- 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