mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Workflow Folio State
This commit is contained in:
@@ -276,16 +276,17 @@ class HotelFolio(models.Model):
|
||||
'amount_total': amount_untaxed + amount_tax,
|
||||
})
|
||||
|
||||
@api.depends('amount_total', 'payment_ids', 'return_ids', 'reservation_type')
|
||||
@api.depends('amount_total', 'payment_ids', 'return_ids',
|
||||
'reservation_type', 'state')
|
||||
@api.multi
|
||||
def compute_amount(self):
|
||||
acc_pay_obj = self.env['account.payment']
|
||||
for record in self:
|
||||
if record.reservation_type in ('staff', 'out'):
|
||||
vals = {
|
||||
'pending_amount': 0,
|
||||
'invoices_paid': 0,
|
||||
'refund_amount': 0,
|
||||
'pending_amount': 0,
|
||||
'invoices_paid': 0,
|
||||
'refund_amount': 0,
|
||||
}
|
||||
record.update(vals)
|
||||
else:
|
||||
@@ -294,10 +295,17 @@ class HotelFolio(models.Model):
|
||||
('folio_id', '=', record.id)
|
||||
])
|
||||
total_paid = sum(pay.amount for pay in payments)
|
||||
return_lines = self.env['payment.return.line'].search([('move_line_ids','in',payments.mapped('move_line_ids.id')),('return_id.state','=', 'done')])
|
||||
return_lines = self.env['payment.return.line'].search([
|
||||
('move_line_ids', 'in', payments.mapped('move_line_ids.id')),
|
||||
('return_id.state', '=', 'done')
|
||||
])
|
||||
total_inv_refund = sum(pay_return.amount for pay_return in return_lines)
|
||||
total = record.amount_total
|
||||
# REVIEW: Must We ignored services in cancelled folios pending amount?
|
||||
if record.state == 'cancelled':
|
||||
total = total - sum(record.service_ids.mapped('price_total'))
|
||||
vals = {
|
||||
'pending_amount': record.amount_total - total_paid + total_inv_refund,
|
||||
'pending_amount': total - total_paid + total_inv_refund,
|
||||
'invoices_paid': total_paid,
|
||||
'refund_amount': total_inv_refund,
|
||||
}
|
||||
@@ -408,7 +416,6 @@ class HotelFolio(models.Model):
|
||||
else:
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('hotel.folio') or _('New')
|
||||
|
||||
|
||||
# Makes sure partner_invoice_id' and 'pricelist_id' are defined
|
||||
lfields = ('partner_invoice_id', 'partner_shipping_id', 'pricelist_id')
|
||||
if any(f not in vals for f in lfields):
|
||||
@@ -471,7 +478,7 @@ class HotelFolio(models.Model):
|
||||
|
||||
@api.onchange('partner_diff_invoicing')
|
||||
def onchange_partner_diff_invoicing(self):
|
||||
if self.partner_diff_invoicing == False:
|
||||
if self.partner_diff_invoicing is False:
|
||||
self.update({'partner_invoice_id': self.partner_id.id})
|
||||
elif self.partner_id == self.partner_invoice_id:
|
||||
self.update({'partner_invoice_id': self.partner_id.address_get(['invoice'])['invoice'] or None})
|
||||
@@ -515,17 +522,14 @@ class HotelFolio(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_cancel(self):
|
||||
'''
|
||||
@param self: object pointer
|
||||
'''
|
||||
pass
|
||||
# for sale in self:
|
||||
# if not sale.order_id:
|
||||
# raise ValidationError(_('Order id is not available'))
|
||||
# for invoice in sale.invoice_ids:
|
||||
# invoice.state = 'cancel'
|
||||
# sale.room_lines.action_cancel()
|
||||
# sale.order_id.action_cancel()
|
||||
for folio in self:
|
||||
for reservation in folio.room_lines.filtered(lambda res:
|
||||
res.state != 'cancelled'):
|
||||
reservation.action_cancel()
|
||||
self.write({
|
||||
'state': 'cancel',
|
||||
})
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def print_quotation(self):
|
||||
@@ -544,13 +548,14 @@ class HotelFolio(models.Model):
|
||||
'state': 'confirm',
|
||||
'confirmation_date': fields.Datetime.now()
|
||||
})
|
||||
#~ if self.env.context.get('send_email'):
|
||||
#~ self.force_quotation_send()
|
||||
|
||||
# if self.env.context.get('send_email'):
|
||||
# self.force_quotation_send()
|
||||
|
||||
# create an analytic account if at least an expense product
|
||||
#~ if any([expense_policy != 'no' for expense_policy in self.order_line.mapped('product_id.expense_policy')]):
|
||||
#~ if not self.analytic_account_id:
|
||||
#~ self._create_analytic_account()
|
||||
# if any([expense_policy != 'no' for expense_policy in self.order_line.mapped('product_id.expense_policy')]):
|
||||
# if not self.analytic_account_id:
|
||||
# self._create_analytic_account()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ class HotelService(models.Model):
|
||||
folio_id = fields.Many2one('hotel.folio', 'Folio',
|
||||
ondelete='cascade',
|
||||
default=_default_folio_id)
|
||||
state = fields.Selection(related='folio_id.state')
|
||||
ser_room_line = fields.Many2one('hotel.reservation', 'Room',
|
||||
default=_default_ser_room_line)
|
||||
per_day = fields.Boolean(related='product_id.per_day', related_sudo=True)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class HotelServiceLine(models.Model):
|
||||
_name = "hotel.service.line"
|
||||
_order = "date"
|
||||
@@ -11,6 +12,7 @@ class HotelServiceLine(models.Model):
|
||||
service_id = fields.Many2one('hotel.service', string='Service Room',
|
||||
ondelete='cascade', required=True,
|
||||
copy=False)
|
||||
active = fields.Boolean('Active', compute="_compute_active")
|
||||
date = fields.Date('Date')
|
||||
day_qty = fields.Integer('Units')
|
||||
product_id = fields.Many2one(related='service_id.product_id', store=True)
|
||||
|
||||
@@ -21,17 +21,15 @@
|
||||
<!-- <button name="send_exit_mail" type="object" string="Send Exit Email"
|
||||
attrs="{'invisible': [('has_checkout_to_send', '=', False)]}" class="oe_highlight"/> -->
|
||||
<button name="%(hotel.action_view_folio_advance_payment_inv)d"
|
||||
string="Create Invoice" type="action" class="btn-primary" states="sale"
|
||||
string="Create Invoice" type="action" class="btn-primary"
|
||||
attrs="{'invisible': [('state', '!=', 'confirm')]}"/>
|
||||
<!-- <button name="action_cancel_draft" states="cancel,sale" string="Set to Draft"
|
||||
type="object" icon="fa-undo" class="oe_highlight" /> -->
|
||||
<button name="action_cancel" string="Cancel Folio" states="sale"
|
||||
type="object" icon="fa-minus-square" class="oe_highlight" />
|
||||
<button name="action_cancel" string="Cancel Folio" states="draft"
|
||||
icon="fa-minus-square" type="object" class="oe_highlight" />
|
||||
<button name="action_cancel" string="Cancel Folio"
|
||||
attrs="{'invisible': [('state', 'not in', ('confirm','draft'))]}"
|
||||
type="object" />
|
||||
<button name="action_done" type="object" string="Set to Done"
|
||||
help="If a Hotel Folio is done, you cannot modify it manually anymore. However, you will still be able to invoice or deliver. This is used to freeze the Hotel Folio." />
|
||||
<!-- states="sale" attrs="{'invisible': [('invoice_status', '!=', 'invoiced')]}" -->
|
||||
help="If a Hotel Folio is done, you cannot modify it manually anymore. However, you will still be able to invoice. This is used to freeze the Hotel Folio." />
|
||||
<!-- <button name="print_quotation" string="Print" type="object" states="sent,sale"/> -->
|
||||
<field name="state" select="2" widget="statusbar"
|
||||
statusbar_visible="draft,sent,sale,done" />
|
||||
@@ -66,7 +64,6 @@
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<!-- <field name="image" widget="image" class="oe_avatar" options="{"preview_image": "image_medium", "size": [90, 90]}"/> -->
|
||||
<h2><field name="name"/></h2>
|
||||
<h1>
|
||||
<field name="partner_id" default_focus="1" placeholder="Guest" attrs="{'invisible':[('reservation_type','in',('out'))]}"/>
|
||||
|
||||
Reference in New Issue
Block a user