[REF]GOLEM Resource Account : add to invoice refactoring / small enhancements
This commit is contained in:
parent
c446fccd03
commit
95cc14a4ee
@ -20,7 +20,7 @@
|
||||
'name': 'GOLEM resources invoicing',
|
||||
'summary': 'GOLEM resources invoicing',
|
||||
'description': ''' GOLEM resources invoicing ''',
|
||||
'version': '10.0.0.1.4',
|
||||
'version': '10.0.0.2.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
""" GOLEM Resource Reservation Adaptation"""
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo import models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@ -31,5 +31,12 @@ class AccountInvoice(models.Model):
|
||||
"""Add reservation to existing invoice """
|
||||
for invoice in self:
|
||||
reservation_id = self._context.get('reservation_id')
|
||||
if not reservation_id:
|
||||
raise ValidationError(_('There is no reservation passed through '
|
||||
'context. Please contact your administrator.'))
|
||||
reservation = self.env['golem.resource.reservation'].browse(reservation_id)
|
||||
if not reservation:
|
||||
raise ValidationError(_('No reservation has been found with {} '
|
||||
'reservation ID. Please contact your '
|
||||
'administrator.'.format(reservation_id)))
|
||||
reservation.create_invoice_line(invoice)
|
||||
|
@ -124,18 +124,17 @@ class GolemResourceReservation(models.Model):
|
||||
partner = reservation.partner_id
|
||||
domain = [('partner_id', '=', partner.id),
|
||||
('state', '=', 'draft')]
|
||||
invoice_list = self.env['account.invoice'].search(domain)
|
||||
#test if none
|
||||
if invoice_list:
|
||||
invoice_ids = invoice_list.mapped('id')
|
||||
return {'name' : ("partner's invoice list"),
|
||||
invoice_ids = self.env['account.invoice'].search(domain)
|
||||
if invoice_ids:
|
||||
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,
|
||||
'context': {'default_invoice_ids': invoice_ids.ids,
|
||||
'default_reservation_id': reservation.id},
|
||||
'view_mode': 'form',
|
||||
'flags': {'initial_mode': 'view'},
|
||||
'target': 'new'}
|
||||
else:
|
||||
raise ValidationError(_('There is no existing invoice for the current client, '
|
||||
'please create new one to invoice this reservation'))
|
||||
raise ValidationError(_('There is no existing invoice for the '
|
||||
'current client, please create new one '
|
||||
'to invoice this reservation'))
|
||||
|
@ -17,33 +17,23 @@
|
||||
# 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 """
|
||||
"""GOLEM Reservation 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")
|
||||
reservation_id = fields.Many2one('golem.resource.reservation')
|
||||
|
||||
@api.multi
|
||||
def add(self):
|
||||
print '__________________hjt______________________'
|
||||
|
||||
"""keyword = fields.Char(required=True)
|
||||
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):
|
||||
|
||||
""" Returns action window with current model and instance """
|
||||
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,
|
||||
@ -51,23 +41,14 @@ class GolemReservationAddToInvoiceWizard(models.TransientModel):
|
||||
'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):
|
||||
|
||||
""" Searches partners in name, email """
|
||||
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()"""
|
||||
'member_ids': [(6, False, partner_ids.mapped('member_id').ids)]})
|
||||
return self[0].action()
|
||||
|
@ -19,20 +19,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="golem_reservation_add_to_invoice_form">
|
||||
<record id="golem_reservation_add_to_invoice_form" model="ir.ui.view">
|
||||
<field name="name">GOLEM Reservation Add to invoice Form</field>
|
||||
<field name="model">golem.reservation.add.to.invoice.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<field name="reservation_id" invisible="1" />
|
||||
<field name="reservation_id" readonly="1" />
|
||||
<field name="invoice_ids" widget="many2many"
|
||||
context="{'reservation_id': reservation_id}"
|
||||
readonly="1">
|
||||
<tree>
|
||||
<field name="partner_id" />
|
||||
<field name="amount_total" />
|
||||
<field name="state"/>
|
||||
<button name="add_to_invoice" type="object" icon="fas fa-plus-square"/>
|
||||
<button name="add_to_invoice" type="object" icon="fa fa-plus-square" />
|
||||
</tree>
|
||||
</field>
|
||||
<footer>
|
||||
|
Loading…
Reference in New Issue
Block a user