mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: Add adults/children board service manage
This commit is contained in:
@@ -44,6 +44,16 @@ class PmsBoardServiceLine(models.Model):
|
||||
inverse="_inverse_amount",
|
||||
digits=("Product Price"),
|
||||
)
|
||||
adults = fields.Boolean(
|
||||
string="Adults",
|
||||
help="Apply service to adults",
|
||||
default=False,
|
||||
)
|
||||
children = fields.Boolean(
|
||||
string="Children",
|
||||
help="Apply service to children",
|
||||
default=False,
|
||||
)
|
||||
|
||||
def _get_default_price(self):
|
||||
if self.product_id:
|
||||
|
||||
@@ -143,6 +143,15 @@ class PmsBoardServiceRoomType(models.Model):
|
||||
board_service = self.env["pms.board.service"].browse(board_service_id)
|
||||
for line in board_service.board_service_line_ids:
|
||||
cmds.append(
|
||||
(0, False, {"product_id": line.product_id.id, "amount": line.amount})
|
||||
(
|
||||
0,
|
||||
False,
|
||||
{
|
||||
"product_id": line.product_id.id,
|
||||
"amount": line.amount,
|
||||
"adults": line.adults,
|
||||
"children": line.children,
|
||||
},
|
||||
)
|
||||
)
|
||||
return {"board_service_line_ids": cmds}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Copyright 2017 Dario Lodeiros
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class PmsBoardServiceRoomTypeLine(models.Model):
|
||||
@@ -40,6 +41,22 @@ class PmsBoardServiceRoomTypeLine(models.Model):
|
||||
default=lambda self: self._default_amount(),
|
||||
digits=("Product Price"),
|
||||
)
|
||||
adults = fields.Boolean(
|
||||
string="Adults",
|
||||
help="Apply service to adults",
|
||||
default=False,
|
||||
)
|
||||
children = fields.Boolean(
|
||||
string="Children",
|
||||
help="Apply service to children",
|
||||
default=False,
|
||||
)
|
||||
|
||||
def _default_amount(self):
|
||||
return self.product_id.list_price
|
||||
|
||||
@api.constrains("adults", "children")
|
||||
def _check_adults_children(self):
|
||||
for record in self:
|
||||
if not record.adults and not record.children:
|
||||
raise ValidationError(_("Adults or Children must be checked"))
|
||||
|
||||
@@ -1008,12 +1008,16 @@ class PmsReservation(models.Model):
|
||||
reservation.board_service_room_id.id
|
||||
)
|
||||
for line in board.board_service_line_ids:
|
||||
res = {
|
||||
"product_id": line.product_id.id,
|
||||
"is_board_service": True,
|
||||
"folio_id": reservation.folio_id.id,
|
||||
"reservation_id": reservation.id,
|
||||
}
|
||||
if (reservation.adults and line.adults) or (
|
||||
reservation.children and line.children
|
||||
):
|
||||
res = {
|
||||
"product_id": line.product_id.id,
|
||||
"is_board_service": True,
|
||||
"folio_id": reservation.folio_id.id,
|
||||
"reservation_id": reservation.id,
|
||||
"board_service_line_id": line.id,
|
||||
}
|
||||
board_services.append((0, False, res))
|
||||
reservation.service_ids -= old_board_lines
|
||||
reservation.service_ids = board_services
|
||||
|
||||
@@ -130,6 +130,12 @@ class PmsService(models.Model):
|
||||
string="Is Board Service",
|
||||
help="Indicates if the service is part of a board service",
|
||||
)
|
||||
board_service_line_id = fields.Many2one(
|
||||
string="Board Service Line",
|
||||
help="Board Service Line in which this service is included",
|
||||
comodel_name="pms.board.service.room.type.line",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
# Non-stored related field to allow portal user to
|
||||
# see the image of the product he has ordered
|
||||
product_image = fields.Binary(
|
||||
@@ -537,7 +543,17 @@ class PmsService(models.Model):
|
||||
# TODO: Pass per_person to service line from product default_per_person
|
||||
# When the user modifies the quantity avoid overwriting
|
||||
if self.product_id.per_person:
|
||||
qty = self.reservation_id.adults
|
||||
if self.is_board_service:
|
||||
qty = (
|
||||
self.reservation.adults if self.board_service_line_id.adults else 0
|
||||
)
|
||||
qty += (
|
||||
self.reservation.children
|
||||
if self.board_service_line_id.children
|
||||
else 0
|
||||
)
|
||||
else:
|
||||
qty = self.reservation_id.adults
|
||||
return qty
|
||||
|
||||
def _get_price_unit_line(self, date=False):
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<form string="Board Service Line">
|
||||
<group>
|
||||
<field name="amount" />
|
||||
<field name="board_service_line_ids">
|
||||
<field name="pms_property_id" />
|
||||
<field name="board_service_line_ids">
|
||||
<tree editable="bottom">
|
||||
<field
|
||||
name="pms_board_service_room_type_id"
|
||||
@@ -16,6 +16,8 @@
|
||||
/>
|
||||
<field name="product_id" />
|
||||
<field name="amount" />
|
||||
<field name="adults" />
|
||||
<field name="children" />
|
||||
<field name="pms_property_id" invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<tree editable="bottom">
|
||||
<field name="product_id" />
|
||||
<field name="amount" />
|
||||
<field name="adults" />
|
||||
<field name="children" />
|
||||
<field name="pms_property_ids" invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user