diff --git a/golem_resource_account/__manifest__.py b/golem_resource_account/__manifest__.py index fb647c3..7e36e7f 100644 --- a/golem_resource_account/__manifest__.py +++ b/golem_resource_account/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM resources invoicing', 'summary': 'GOLEM resources invoicing', 'description': ''' GOLEM resources invoicing ''', - 'version': '10.0.0.1.3', + 'version': '10.0.0.1.4', 'category': 'GOLEM', 'author': 'Youssef El Ouahby, Fabien Bourgeois', 'license': 'AGPL-3', @@ -28,5 +28,6 @@ 'installable': True, 'depends': ['golem_resource', 'account'], 'data': ['wizard/golem_reservation_invoice_views.xml', - 'views/golem_resource_reservation_views.xml'] + 'views/golem_resource_reservation_views.xml', + 'wizard/golem_reservation_add_to_invoice_views.xml'] } diff --git a/golem_resource_account/models/golem_resource_reservation.py b/golem_resource_account/models/golem_resource_reservation.py index a18ad91..3704cb0 100644 --- a/golem_resource_account/models/golem_resource_reservation.py +++ b/golem_resource_account/models/golem_resource_reservation.py @@ -117,3 +117,19 @@ class GolemResourceReservation(models.Model): 'res_id': reservation.invoice_id.id, 'view_mode': 'form', 'view_id': self.env.ref('account.invoice_form').id} + @api.multi + def add_to_invoice(self): + """ Add reservation to existing invoice""" + for reservation in self: + partner = reservation.partner_id + invoice_list = self.env['account.invoice'].search([('partner_id', '=', partner.id), + ('state', '=', 'draft')]) + #test if none + invoice_ids = invoice_list.mapped('id') + return {'name' : ("partner's invoice list"), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.reservation.add.to.invoice.wizard', + 'context': {'default_invoice_ids': invoice_ids}, + 'view_mode': 'form', + 'flags': {'initial_mode': 'view'}, + 'target': 'new'} diff --git a/golem_resource_account/views/golem_resource_reservation_views.xml b/golem_resource_account/views/golem_resource_reservation_views.xml index a17150c..b544466 100644 --- a/golem_resource_account/views/golem_resource_reservation_views.xml +++ b/golem_resource_account/views/golem_resource_reservation_views.xml @@ -43,6 +43,8 @@ along with this program. If not, see . attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('resource_product_id', '=', False), ('invoice_id', '!=', False)]}" /> . -from . import golem_reservation_invoice +from . import golem_reservation_invoice, \ +golem_reservation_add_to_invoice diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice.py b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py new file mode 100644 index 0000000..635d2fc --- /dev/null +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 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 Reservation's Adding to invoice wizard""" + +import logging +from odoo import models, fields, api, _ +_LOGGER = logging.getLogger(__name__) + +class GolemReservationAddToInvoiceWizard(models.TransientModel): + """GOLEM Resrvation Add to Invoice Wizard """ + _name = 'golem.reservation.add.to.invoice.wizard' + + state = fields.Selection([('init', 'Init'), ('final', 'Final')], + default='init') + invoice_ids = fields.Many2many('account.invoice', string="Partner invoice list") + + """keyword = fields.Char(required=True) + member_ids = fields.Many2many('golem.member', string='Members') + contact_ids = fields.Many2many('res.partner', string='Contacts') + + @api.multi + def action(self): + + self.ensure_one() + _LOGGER.warning(self[0].contact_ids) + _LOGGER.warning(self[0].member_ids) + return {'name' : _('Search results'), + 'type' : 'ir.actions.act_window', + 'res_model' : self._name, + 'res_id': self[0].id, + 'view_mode': 'form', + 'target': 'new'} + + @api.multi + def new_search(self): + + self[0].write({'member_ids': [(6, False, [])], + 'contact_ids': [(6, False, [])], + 'state': 'init'}) + return self[0].action() + + @api.multi + def search_partners(self): + + self.ensure_one() + domain = ['|', + ('name', 'ilike', self[0].keyword), + ('email', 'ilike', self[0].keyword)] + partner_ids = self.env['res.partner'].search(domain) + self[0].write({'contact_ids': [(6, False, partner_ids.ids)], + 'member_ids': [(6, False, partner_ids.mapped('member_id').ids)], + 'state': 'final'}) + return self[0].action()""" diff --git a/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml new file mode 100644 index 0000000..4b78b01 --- /dev/null +++ b/golem_resource_account/wizard/golem_reservation_add_to_invoice_views.xml @@ -0,0 +1,85 @@ + + + + + + + GOLEM Member Precreation Search Form + golem.reservation.add.to.invoice.wizard + +
+ + + + +
+ + + +
+