mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
Merge branch '14.0' into 14.0-pms-minimize-split-rooms
This commit is contained in:
@@ -2,3 +2,4 @@
|
|||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizards
|
from . import wizards
|
||||||
|
from .init_hook import post_init_hook
|
||||||
|
|||||||
@@ -73,4 +73,5 @@
|
|||||||
"qweb": [
|
"qweb": [
|
||||||
"static/src/xml/pms_base_templates.xml",
|
"static/src/xml/pms_base_templates.xml",
|
||||||
],
|
],
|
||||||
|
"post_init_hook": "post_init_hook",
|
||||||
}
|
}
|
||||||
|
|||||||
10
pms/init_hook.py
Normal file
10
pms/init_hook.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from odoo import SUPERUSER_ID
|
||||||
|
from odoo.api import Environment
|
||||||
|
|
||||||
|
|
||||||
|
def post_init_hook(cr, _):
|
||||||
|
with Environment.manage():
|
||||||
|
env = Environment(cr, SUPERUSER_ID, {})
|
||||||
|
env["ir.config_parameter"].sudo().set_param(
|
||||||
|
"product.product_pricelist_setting", "advanced"
|
||||||
|
)
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
from . import ir_http
|
from . import ir_http
|
||||||
from . import ir_sequence
|
from . import ir_sequence
|
||||||
|
from . import ir_config_parameter
|
||||||
|
|
||||||
# from . import payment_return
|
# from . import payment_return
|
||||||
from . import pms_board_service_room_type
|
from . import pms_board_service_room_type
|
||||||
|
|||||||
22
pms/models/ir_config_parameter.py
Normal file
22
pms/models/ir_config_parameter.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from odoo import _, api, models
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class IrConfigParameter(models.Model):
|
||||||
|
_inherit = "ir.config_parameter"
|
||||||
|
|
||||||
|
def unlink(self):
|
||||||
|
for record in self:
|
||||||
|
if (
|
||||||
|
record.key == "product.product_pricelist_setting"
|
||||||
|
and record.value == "advanced"
|
||||||
|
):
|
||||||
|
raise ValidationError(_("Cannot delete this parameter"))
|
||||||
|
return super().unlink()
|
||||||
|
|
||||||
|
@api.constrains("key", "value")
|
||||||
|
def check_value(self):
|
||||||
|
if self.key == "product.product_pricelist_setting" and self.value != "advanced":
|
||||||
|
raise ValidationError(
|
||||||
|
_("The parameter Advanced price rules cannot be modified")
|
||||||
|
)
|
||||||
@@ -225,6 +225,10 @@ class PmsReservation(models.Model):
|
|||||||
store=True,
|
store=True,
|
||||||
readonly=False,
|
readonly=False,
|
||||||
)
|
)
|
||||||
|
children_occupying = fields.Integer(
|
||||||
|
string="Children occupying",
|
||||||
|
)
|
||||||
|
|
||||||
children = fields.Integer(
|
children = fields.Integer(
|
||||||
"Children",
|
"Children",
|
||||||
readonly=False,
|
readonly=False,
|
||||||
@@ -959,7 +963,7 @@ class PmsReservation(models.Model):
|
|||||||
_logger.info("Modified Reservation - No Penalty")
|
_logger.info("Modified Reservation - No Penalty")
|
||||||
record.write({"state": "cancelled", "cancelled_reason": cancel_reason})
|
record.write({"state": "cancelled", "cancelled_reason": cancel_reason})
|
||||||
# record._compute_cancelled_discount()
|
# record._compute_cancelled_discount()
|
||||||
record.folio_id.compute_amount()
|
record.folio_id._compute_amount()
|
||||||
|
|
||||||
def compute_cancelation_reason(self):
|
def compute_cancelation_reason(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|||||||
@@ -368,8 +368,9 @@ class PmsReservationLine(models.Model):
|
|||||||
extra_bed = record.reservation_id.service_ids.filtered(
|
extra_bed = record.reservation_id.service_ids.filtered(
|
||||||
lambda r: r.product_id.is_extra_bed is True
|
lambda r: r.product_id.is_extra_bed is True
|
||||||
)
|
)
|
||||||
if record.reservation_id.adults > record.room_id.get_capacity(
|
if (
|
||||||
len(extra_bed)
|
record.reservation_id.adults + record.reservation_id.children_occupying
|
||||||
|
> record.room_id.get_capacity(len(extra_bed))
|
||||||
):
|
):
|
||||||
raise ValidationError(_("Persons can't be higher than room capacity"))
|
raise ValidationError(_("Persons can't be higher than room capacity"))
|
||||||
# if record.reservation_id.adults == 0:
|
# if record.reservation_id.adults == 0:
|
||||||
|
|||||||
@@ -20,3 +20,4 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from . import test_pms_reservation
|
from . import test_pms_reservation
|
||||||
|
from . import test_pms_pricelist
|
||||||
|
|||||||
39
pms/tests/test_pms_pricelist.py
Normal file
39
pms/tests/test_pms_pricelist.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tests import common, tagged
|
||||||
|
|
||||||
|
|
||||||
|
@tagged("standard", "nice")
|
||||||
|
class TestPmsPricelist(common.TransactionCase):
|
||||||
|
def test_advanced_pricelist_exists(self):
|
||||||
|
|
||||||
|
# ARRANGE
|
||||||
|
key = "product.product_pricelist_setting"
|
||||||
|
value = "advanced"
|
||||||
|
|
||||||
|
# ACT
|
||||||
|
found_value = self.env["ir.config_parameter"].sudo().get_param(key)
|
||||||
|
|
||||||
|
# ASSERT
|
||||||
|
self.assertEqual(found_value, value, "Parameter doesn't exist")
|
||||||
|
|
||||||
|
def test_product_pricelist_setting_modified(self):
|
||||||
|
|
||||||
|
# ARRANGE
|
||||||
|
key = "product.product_pricelist_setting"
|
||||||
|
value = "basic"
|
||||||
|
|
||||||
|
# ACT & ASSERT
|
||||||
|
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||||
|
self.env["ir.config_parameter"].set_param(key, value)
|
||||||
|
|
||||||
|
def test_product_pricelist_setting_unlink(self):
|
||||||
|
|
||||||
|
# ARRANGE
|
||||||
|
key = "product.product_pricelist_setting"
|
||||||
|
value = "advanced"
|
||||||
|
|
||||||
|
# ACT & ASSERT
|
||||||
|
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||||
|
self.env["ir.config_parameter"].search(
|
||||||
|
[("key", "=", key), ("value", "=", value)]
|
||||||
|
).unlink()
|
||||||
@@ -7,6 +7,7 @@ from odoo.exceptions import ValidationError
|
|||||||
|
|
||||||
from .common import TestHotel
|
from .common import TestHotel
|
||||||
|
|
||||||
|
@freeze_time("2012-01-14")
|
||||||
class TestPmsReservations(TestHotel):
|
class TestPmsReservations(TestHotel):
|
||||||
|
|
||||||
def create_common_scenario(self):
|
def create_common_scenario(self):
|
||||||
@@ -489,3 +490,22 @@ class TestPmsReservations(TestHotel):
|
|||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
r_test.flush()
|
r_test.flush()
|
||||||
|
|
||||||
|
|
||||||
|
def test_manage_children_raise(self):
|
||||||
|
|
||||||
|
# ARRANGE
|
||||||
|
PmsReservation = self.env["pms.reservation"]
|
||||||
|
|
||||||
|
# ACT & ASSERT
|
||||||
|
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||||
|
|
||||||
|
PmsReservation.create(
|
||||||
|
{
|
||||||
|
"adults": 2,
|
||||||
|
"children_occupying": 1,
|
||||||
|
"checkin": datetime.datetime.now(),
|
||||||
|
"checkout": datetime.datetime.now() + datetime.timedelta(days=1),
|
||||||
|
"room_type_id": self.browse_ref("pms.pms_room_type_0").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -302,6 +302,10 @@
|
|||||||
name="children"
|
name="children"
|
||||||
attrs="{'invisible': [('reservation_type','in',('out'))]}"
|
attrs="{'invisible': [('reservation_type','in',('out'))]}"
|
||||||
/>
|
/>
|
||||||
|
<field
|
||||||
|
name="children_occupying"
|
||||||
|
attrs="{'invisible': [('children', '=', 0)]}"
|
||||||
|
/>
|
||||||
<field name="qty_invoiced" invisible="1" />
|
<field name="qty_invoiced" invisible="1" />
|
||||||
<field name="qty_to_invoice" invisible="1" />
|
<field name="qty_to_invoice" invisible="1" />
|
||||||
<field name="allowed_room_ids" invisible="1" />
|
<field name="allowed_room_ids" invisible="1" />
|
||||||
|
|||||||
Reference in New Issue
Block a user