mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] reservation views
This commit is contained in:
@@ -708,10 +708,10 @@ class PmsFolio(models.Model):
|
||||
# Compute 'payment_state'.
|
||||
if total <= paid_out:
|
||||
payment_state = "paid"
|
||||
elif paid_out < total:
|
||||
payment_state = "partial"
|
||||
else:
|
||||
elif paid_out <= 0:
|
||||
payment_state = "not_paid"
|
||||
else:
|
||||
payment_state = "partial"
|
||||
vals = {
|
||||
"pending_amount": total - paid_out,
|
||||
"invoices_paid": paid_out,
|
||||
@@ -723,9 +723,24 @@ class PmsFolio(models.Model):
|
||||
|
||||
def action_pay(self):
|
||||
self.ensure_one()
|
||||
action = self.env.ref("pms.action_payment_folio").sudo().read()[0]
|
||||
action["res_id"] = self.id
|
||||
return action
|
||||
self.ensure_one()
|
||||
partner = self.partner_id.id
|
||||
amount = self.pending_amount
|
||||
view_id = self.env.ref("pms.wizard_payment_folio_view_form").id
|
||||
return {
|
||||
"name": _("Register Payment"),
|
||||
"view_type": "form",
|
||||
"view_mode": "form",
|
||||
"res_model": "wizard.payment.folio",
|
||||
"type": "ir.actions.act_window",
|
||||
"view_id": view_id,
|
||||
"context": {
|
||||
"default_folio_id": self.id,
|
||||
"default_amount": amount,
|
||||
"default_partner_id": partner,
|
||||
},
|
||||
"target": "new",
|
||||
}
|
||||
|
||||
def open_moves_folio(self):
|
||||
invoices = self.mapped("move_ids")
|
||||
|
||||
@@ -365,6 +365,11 @@ class PmsReservation(models.Model):
|
||||
"Detail Origin", compute="_compute_detail_origin", store=True
|
||||
)
|
||||
folio_pending_amount = fields.Monetary(related="folio_id.pending_amount")
|
||||
folio_payment_state = fields.Selection(
|
||||
related="folio_id.payment_state",
|
||||
string="Payment State",
|
||||
store=True,
|
||||
)
|
||||
shared_folio = fields.Boolean(compute="_compute_shared")
|
||||
# Used to notify is the reservation folio has other reservations/services
|
||||
email = fields.Char("E-mail", related="partner_id.email")
|
||||
@@ -1196,31 +1201,6 @@ class PmsReservation(models.Model):
|
||||
self.ensure_one()
|
||||
return self.folio_id.action_pay()
|
||||
|
||||
def action_pay_reservation(self):
|
||||
self.ensure_one()
|
||||
partner = self.partner_id.id
|
||||
amount = min(self.price_room_services_set, self.folio_pending_amount)
|
||||
note = self.folio_id.name + " (" + self.name + ")"
|
||||
view_id = self.env.ref("pms.account_payment_view_form_folio").id
|
||||
return {
|
||||
"name": _("Register Payment"),
|
||||
"view_type": "form",
|
||||
"view_mode": "form",
|
||||
"res_model": "account.payment",
|
||||
"type": "ir.actions.act_window",
|
||||
"view_id": view_id,
|
||||
"context": {
|
||||
"default_folio_id": self.folio_id.id,
|
||||
"default_room_id": self.id,
|
||||
"default_amount": amount,
|
||||
"default_payment_type": "inbound",
|
||||
"default_partner_type": "customer",
|
||||
"default_partner_id": partner,
|
||||
"default_communication": note,
|
||||
},
|
||||
"target": "new",
|
||||
}
|
||||
|
||||
def open_reservation_wizard(self):
|
||||
rooms_available = self.env["pms.room.type.availability.plan"].rooms_available(
|
||||
checkin=self.checkin,
|
||||
|
||||
@@ -94,19 +94,20 @@ class ResPartner(models.Model):
|
||||
if not record.is_agency and record.sale_channel_id:
|
||||
record.sale_channel_id = None
|
||||
|
||||
@api.constrains("mobile", "email")
|
||||
def _check_duplicated(self):
|
||||
for record in self:
|
||||
partner, field = record._search_duplicated()
|
||||
if partner:
|
||||
raise models.ValidationError(
|
||||
_(
|
||||
"Partner %s found with same %s (%s)",
|
||||
partner.name,
|
||||
partner._fields[field].string,
|
||||
getattr(record, field),
|
||||
)
|
||||
)
|
||||
# REVIEW: problems with odoo demo data
|
||||
# @api.constrains("mobile", "email")
|
||||
# def _check_duplicated(self):
|
||||
# for record in self:
|
||||
# partner, field = record._search_duplicated()
|
||||
# if partner:
|
||||
# raise models.ValidationError(
|
||||
# _(
|
||||
# "Partner %s found with same %s (%s)",
|
||||
# partner.name,
|
||||
# partner._fields[field].string,
|
||||
# getattr(record, field),
|
||||
# )
|
||||
# )
|
||||
|
||||
def _search_duplicated(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -541,7 +541,7 @@
|
||||
<field name="view_mode">tree,form,graph</field>
|
||||
</record>
|
||||
<menuitem
|
||||
id="menu_all_folio"
|
||||
id="menu_reservations"
|
||||
name="Reservations"
|
||||
parent="pms.pms_management_menu"
|
||||
sequence="4"
|
||||
|
||||
@@ -149,6 +149,17 @@
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<widget
|
||||
name="web_ribbon"
|
||||
title="Paid"
|
||||
attrs="{'invisible': [('folio_payment_state', '!=', 'paid')]}"
|
||||
/>
|
||||
<widget
|
||||
name="web_ribbon"
|
||||
title="Partial"
|
||||
bg_color="bg-warning"
|
||||
attrs="{'invisible': [('folio_payment_state', '!=', 'partial')]}"
|
||||
/>
|
||||
<span
|
||||
class="label label-danger"
|
||||
attrs="{'invisible': [('state', 'not in', ('cancelled'))]}"
|
||||
@@ -297,6 +308,7 @@
|
||||
<field name="qty_invoiced" invisible="1" />
|
||||
<field name="qty_to_invoice" invisible="1" />
|
||||
<field name="allowed_room_ids" invisible="1" />
|
||||
<field name="folio_payment_state" invisible="1" />
|
||||
<field
|
||||
name="room_type_id"
|
||||
on_change="1"
|
||||
@@ -620,6 +632,15 @@
|
||||
widget="badge"
|
||||
optional="show"
|
||||
/>
|
||||
<field
|
||||
name="folio_payment_state"
|
||||
decoration-success="folio_payment_state == 'paid'"
|
||||
decoration-danger="folio_payment_state == 'not_paid' and state in ['cancelled','onboard','done','no_show','no_checkout']"
|
||||
decoration-info="folio_payment_state == 'not_paid' and state in ['draft','confirm',]"
|
||||
decoration-warning="folio_payment_state == 'partial'"
|
||||
widget="badge"
|
||||
optional="show"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -809,6 +830,11 @@
|
||||
<searchpanel>
|
||||
<field name="room_type_id" string="Room Type" enable_counters="1" />
|
||||
<field name="pricelist_id" string="Pricelist" enable_counters="1" />
|
||||
<field
|
||||
name="channel_type_id"
|
||||
string="Channel"
|
||||
enable_counters="1"
|
||||
/>
|
||||
<field name="agency_id" string="Channel" enable_counters="1" />
|
||||
<field
|
||||
name="state"
|
||||
@@ -816,6 +842,12 @@
|
||||
enable_counters="1"
|
||||
select="multi"
|
||||
/>
|
||||
<field
|
||||
name="folio_payment_state"
|
||||
string="State"
|
||||
enable_counters="1"
|
||||
select="multi"
|
||||
/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
@@ -11,25 +11,10 @@ class WizardPaymentFolio(models.TransientModel):
|
||||
_name = "wizard.payment.folio"
|
||||
_description = "Payments"
|
||||
|
||||
@api.model
|
||||
def default_folio_id(self):
|
||||
return self.env["pms.folio"].browse(self._context.get("active_id", [])).id
|
||||
|
||||
@api.model
|
||||
def _default_amount(self):
|
||||
folio = self.env["pms.folio"].browse(self._context.get("active_id", []))
|
||||
return folio.pending_amount
|
||||
|
||||
@api.model
|
||||
def _default_partner(self):
|
||||
folio = self.env["pms.folio"].browse(self._context.get("active_id", []))
|
||||
return folio.partner_id.id
|
||||
|
||||
folio_id = fields.Many2one(
|
||||
"pms.folio",
|
||||
string="Folio",
|
||||
required=True,
|
||||
default=default_folio_id,
|
||||
)
|
||||
reservation_ids = fields.Many2many(
|
||||
"pms.reservation",
|
||||
@@ -53,9 +38,9 @@ class WizardPaymentFolio(models.TransientModel):
|
||||
compute="_compute_allowed_method_ids",
|
||||
store="True",
|
||||
)
|
||||
amount = fields.Float("Amount", digits=("Product Price"), default=_default_amount)
|
||||
amount = fields.Float("Amount", digits=("Product Price"))
|
||||
date = fields.Date("Date", default=fields.Date.context_today, required=True)
|
||||
partner_id = fields.Many2one("res.partner", default=_default_partner)
|
||||
partner_id = fields.Many2one("res.partner")
|
||||
|
||||
@api.depends("folio_id")
|
||||
def _compute_allowed_method_ids(self):
|
||||
|
||||
Reference in New Issue
Block a user