list des factures du meme clients

This commit is contained in:
eloyoussef 2018-04-03 12:33:31 +02:00
parent fa635b496e
commit 08eb3ecb4b
6 changed files with 176 additions and 3 deletions

View File

@ -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']
}

View File

@ -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'}

View File

@ -43,6 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('resource_product_id', '=', False), ('invoice_id', '!=', False)]}" />
<button name="show_invoice" type="object" string="Show invoice" class="oe_highlight"
attrs="{'invisible': [('invoice_id', '=', False)]}" />
<button name="add_to_invoice" type="object" string="Add To Invoice" class="oe_highlight"
attrs="{'invisible': ['|', ('state', '!=', 'validated'), '|', ('resource_product_id', '=', False), ('invoice_id', '!=', False)]}" />
</button>
<group name="reservation" position="after">
<group name="invoicing" string="Invoicing"

View File

@ -17,4 +17,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from . import golem_reservation_invoice
from . import golem_reservation_invoice, \
golem_reservation_add_to_invoice

View File

@ -0,0 +1,68 @@
# -*- 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 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()"""

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="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/>.
-->
<odoo>
<data>
<record model="ir.ui.view" id="golem_member_precreation_search_view_form">
<field name="name">GOLEM Member Precreation Search Form</field>
<field name="model">golem.reservation.add.to.invoice.wizard</field>
<field name="arch" type="xml">
<form>
<field name="state" invisible="1"/>
<field name="invoice_ids" readonly="1"/>
</form>
</field>
</record>
<!--<record model="ir.ui.view" id="golem_member_precreation_search_view_form">
<field name="name">GOLEM Member Precreation Search Form</field>
<field name="model">golem.member.precreation.search</field>
<field name="arch" type="xml">
<form>
<field name="state" invisible="1" />
<group>
<p colspan="2" states="init">
Please enter a keyword. It will be searched, as case-insensitive, into firstname, lastname and emails.
</p>
<field name="keyword" attrs="{'readonly': [('state', '=', 'final')]}" />
</group>
<group states="final">
<p colspan="2" attrs="{'invisible': [('member_ids', '!=', [])]}">
No member found for the current search.
</p>
<field name="member_ids" readonly="1"
attrs="{'invisible': [('member_ids', '=', [])]}">
<tree>
<field name="id" invisible="1"/>
<field name="firstname"/>
<field name="lastname"/>
<field name="email"/>
<button name="navigate_to_contact" type="object" icon="fa fa-external-link" />
</tree>
</field>
<p colspan="2" attrs="{'invisible': [('contact_ids', '!=', [])]}">
No contact found for the current search.
</p>
<field name="contact_ids" readonly="1"
attrs="{'invisible': [('contact_ids', '=', [])]}">
<tree>
<field name="id" invisible="1"/>
<field name="firstname"/>
<field name="lastname"/>
<field name="email"/>
<button name="navigate_to_contact" type="object" icon="fa fa-external-link" />
</tree>
</field>
</group>
<footer>
<button name="search_partners" string="Search Members and Contacts"
type="object" class="oe_highlight" states="init" />
<button name="new_search" string="New search"
type="object" states="final" />
<button string="Close" special="cancel" />
</footer>
</form>
</field>
</record>-->
</data>
</odoo>