mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[ADD] Control invoived by day
This commit is contained in:
@@ -27,13 +27,6 @@ class HotelFolio(models.Model):
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin', 'portal.mixin']
|
||||
_order = 'id'
|
||||
|
||||
# @api.depends('invoice_lines.invoice_id.state', 'invoice_lines.quantity')
|
||||
def _get_invoice_qty(self):
|
||||
pass
|
||||
# @api.depends('product_id.invoice_policy', 'order_id.state')
|
||||
def _compute_qty_delivered_updateable(self):
|
||||
pass
|
||||
|
||||
@api.model
|
||||
def _default_diff_invoicing(self):
|
||||
"""
|
||||
@@ -56,7 +49,6 @@ class HotelFolio(models.Model):
|
||||
invoice. This is also the default value if the conditions of no other status is met.
|
||||
- to invoice: if any Folio line is 'to invoice', the whole Folio is 'to invoice'
|
||||
- invoiced: if all Folio lines are invoiced, the Folio is invoiced.
|
||||
- upselling: if all Folio lines are invoiced or upselling, the status is upselling.
|
||||
|
||||
The invoice_ids are obtained thanks to the invoice lines of the Folio lines, and we also search
|
||||
for possible refunds created directly from existing invoices. This is necessary since such a
|
||||
@@ -78,30 +70,26 @@ class HotelFolio(models.Model):
|
||||
|
||||
# Ignore the status of the deposit product
|
||||
deposit_product_id = self.env['sale.advance.payment.inv']._default_product_id()
|
||||
#~ line_invoice_status = [line.invoice_status for line in order.order_line if line.product_id != deposit_product_id]
|
||||
service_invoice_status = [service.invoice_status for service in folio.service_ids if service.product_id != deposit_product_id]
|
||||
reservation_invoice_status = [reservation.invoice_status for reservation in folio.room_lines]
|
||||
|
||||
#~ TODO: REVIEW INVOICE_STATUS
|
||||
#~ if folio.state not in ('confirm', 'done'):
|
||||
#~ invoice_status = 'no'
|
||||
#~ elif any(invoice_status == 'to invoice' for invoice_status in line_invoice_status):
|
||||
#~ invoice_status = 'to invoice'
|
||||
#~ elif all(invoice_status == 'invoiced' for invoice_status in line_invoice_status):
|
||||
#~ invoice_status = 'invoiced'
|
||||
#~ elif all(invoice_status in ['invoiced', 'upselling'] for invoice_status in line_invoice_status):
|
||||
#~ invoice_status = 'upselling'
|
||||
#~ else:
|
||||
#~ invoice_status = 'no'
|
||||
if folio.state not in ('confirm', 'done'):
|
||||
invoice_status = 'no'
|
||||
elif any(invoice_status == 'to invoice' for invoice_status in service_invoice_status) or \
|
||||
any(invoice_status == 'to invoice' for invoice_status in reservation_invoice_status):
|
||||
invoice_status = 'to invoice'
|
||||
elif all(invoice_status == 'invoiced' for invoice_status in service_invoice_status) or \
|
||||
any(invoice_status == 'invoiced' for invoice_status in reservation_invoice_status):
|
||||
invoice_status = 'invoiced'
|
||||
else:
|
||||
invoice_status = 'no'
|
||||
|
||||
folio.update({
|
||||
'invoice_count': len(set(invoice_ids.ids + refund_ids.ids)),
|
||||
'invoice_ids': invoice_ids.ids + refund_ids.ids,
|
||||
#~ 'invoice_status': invoice_status
|
||||
'invoice_status': invoice_status
|
||||
})
|
||||
|
||||
# @api.depends('state', 'product_uom_qty', 'qty_delivered', 'qty_to_invoice', 'qty_invoiced')
|
||||
def _compute_invoice_status(self):
|
||||
pass
|
||||
|
||||
@api.model
|
||||
def _get_default_team(self):
|
||||
return self.env['crm.team']._get_default_team_id()
|
||||
@@ -210,12 +198,11 @@ class HotelFolio(models.Model):
|
||||
invoice_count = fields.Integer(compute='_get_invoiced')
|
||||
invoice_ids = fields.Many2many('account.invoice', string='Invoices',
|
||||
compute='_get_invoiced', readonly=True, copy=False)
|
||||
invoice_status = fields.Selection([('upselling', 'Upselling Opportunity'),
|
||||
('invoiced', 'Fully Invoiced'),
|
||||
invoice_status = fields.Selection([('invoiced', 'Fully Invoiced'),
|
||||
('to invoice', 'To Invoice'),
|
||||
('no', 'Nothing to Invoice')],
|
||||
string='Invoice Status',
|
||||
compute='_compute_invoice_status',
|
||||
compute='_get_invoiced',
|
||||
store=True, readonly=True, default='no')
|
||||
partner_invoice_id = fields.Many2one('res.partner',
|
||||
string='Invoice Address', required=True,
|
||||
|
||||
@@ -828,6 +828,8 @@ class HotelReservation(models.Model):
|
||||
record.reservation_line_ids.update({
|
||||
'cancel_discount': 0
|
||||
})
|
||||
if record.folio_id.state != 'confirm':
|
||||
record.folio_id.action_confirm()
|
||||
|
||||
if record.splitted:
|
||||
master_reservation = record.parent_reservation or record
|
||||
@@ -1390,6 +1392,13 @@ class HotelReservation(models.Model):
|
||||
'default_folio_id': self.folio_id.id}
|
||||
return action
|
||||
|
||||
@api.multi
|
||||
def create_invoice(self):
|
||||
action = self.env.ref('hotel.action_view_folio_advance_payment_inv').read()[0]
|
||||
action['context'] = {'default_reservation_id': self.id,
|
||||
'default_folio_id': self.folio_id.id}
|
||||
return action
|
||||
|
||||
@api.multi
|
||||
def _compute_tax_ids(self):
|
||||
for record in self:
|
||||
|
||||
@@ -124,7 +124,8 @@
|
||||
context="{'from_room':False,'folio_id': id,'tree_view_ref':'hotel.hotel_service_view_tree', 'form_view_ref':'hotel.hotel_service_view_form'}"
|
||||
nolabel="1" />
|
||||
</page>
|
||||
<page name="persons" string="Persons">
|
||||
<!--TODO: Add precheckin with indeterminate select room?? -->
|
||||
<page name="persons" string="Persons" invisible="1">
|
||||
<field name="checkin_partner_ids"
|
||||
context="{
|
||||
'default_reservation_id': id,
|
||||
@@ -220,6 +221,8 @@
|
||||
<field name="date_order" select="1"/>
|
||||
<field name="room_lines" widget="many2many_tags" />
|
||||
<field name="amount_total" sum="Total amount"/>
|
||||
<field name="pending_amount" sum="Total debt"/>
|
||||
<field name="invoice_status" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -271,9 +274,16 @@
|
||||
<field name="arch" type="xml">
|
||||
<search string="Tables Detail">
|
||||
<field name="partner_id" />
|
||||
<field name="partner_invoice_id" />
|
||||
<filter name="to_invoice" string="To invoice"
|
||||
domain="[('invoice_status', '=', 'to invoice')]" />
|
||||
<filter name="payment_pending" string="Payment Pending"
|
||||
domain="[('pending_amount', '>', 0)]" />
|
||||
<group expand="0" string="Group By">
|
||||
<filter string="Customer" icon="terp-stock_symbol-selection"
|
||||
context="{'group_by':'partner_id'}" />
|
||||
<filter string="Invoice Contact"
|
||||
context="{'group_by':'partner_invoice_id'}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
<field name="has_cancelled_reservations_to_send" invisible="1" />
|
||||
<field name="has_checkout_to_send" invisible="1" />
|
||||
<field name="checkin_partner_count" invisible="1" />
|
||||
<button name="open_invoices_reservation"
|
||||
<button name="create_invoice"
|
||||
string="Create Invoice" type="object" class="btn-primary" states="sale"
|
||||
attrs="{'invisible': ['|',('state', '=', 'draft'), ('reservation_type','not in',('normal'))]}" />
|
||||
attrs="{'invisible': ['|','|',
|
||||
('state', '=', 'draft'), ('reservation_type','not in',('normal')),
|
||||
('invoice_status','!=', 'to invoice')]}" />
|
||||
<button name="send_reservation_mail" type="object" string="Send Confirmation Email"
|
||||
attrs="{'invisible': [('has_confirmed_reservations_to_send', '=', False)]}"/>
|
||||
<button name="send_cancel_mail" type="object" string="Send Cancel Email"
|
||||
|
||||
@@ -291,6 +291,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
for folio in folios:
|
||||
for service in folio.service_ids.filtered(
|
||||
lambda x: x.is_board_service == False and \
|
||||
x.invoice_status == 'invoice_status' and \
|
||||
(x.ser_room_line.id in self.reservation_ids.ids or \
|
||||
x.ser_room_line.id == False)):
|
||||
invoice_lines[service.id] = {
|
||||
@@ -302,9 +303,11 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
'service_id': service.id,
|
||||
}
|
||||
for reservation in folio.room_lines.filtered(
|
||||
lambda x: x.id in self.reservation_ids.ids):
|
||||
lambda x: x.id in self.reservation_ids.ids and
|
||||
x.invoice_status == 'to invoice'):
|
||||
board_service = reservation.board_service_room_id
|
||||
for day in reservation.reservation_line_ids.sorted('date'):
|
||||
for day in reservation.reservation_line_ids.filtered(
|
||||
lambda x: not x.invoice_line_ids).sorted('date'):
|
||||
extra_price = 0
|
||||
if board_service:
|
||||
services = reservation.service_ids.filtered(
|
||||
|
||||
@@ -30,7 +30,11 @@
|
||||
<group>
|
||||
<field name="group_folios" string="Add Folios"/>
|
||||
</group>
|
||||
<field name="folio_ids" attrs="{'invisible': [('group_folios', '=', False)]}">
|
||||
<field name="folio_ids"
|
||||
attrs="{'invisible': [('group_folios', '=', False)]}"
|
||||
domain="[('invoice_status','=','to invoice')]"
|
||||
context="{'search_default_partner_invoice_id': partner_invoice_id}"
|
||||
>
|
||||
<tree string="Folios" editable="bottom"
|
||||
decoration-danger="partner_invoice_id != parent.partner_invoice_id">
|
||||
<field name="partner_invoice_id" />
|
||||
|
||||
Reference in New Issue
Block a user