mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[RFC] Code review (#91)
* [REF] Refactor wizard models * [REF] Refactor in pms models
This commit is contained in:
@@ -10,6 +10,78 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
_name = "folio.advance.payment.inv"
|
||||
_description = "Folio Advance Payment Invoice"
|
||||
|
||||
partner_invoice_id = fields.Many2one(
|
||||
string="Billing contact",
|
||||
help="Invoice address for current partner",
|
||||
default=lambda self: self._default_partner_invoice_id,
|
||||
comodel_name="res.partner",
|
||||
)
|
||||
advance_payment_method = fields.Selection(
|
||||
string="Create Invoice",
|
||||
help="A standard invoice is issued with all the order \
|
||||
lines ready for invoicing, \
|
||||
according to their invoicing policy \
|
||||
(based on ordered or delivered quantity).",
|
||||
required=True,
|
||||
default="delivered",
|
||||
selection=[
|
||||
("delivered", "Regular invoice"),
|
||||
("percentage", "Down payment (percentage)"),
|
||||
("fixed", "Down payment (fixed amount)"),
|
||||
],
|
||||
)
|
||||
bill_services = fields.Boolean(
|
||||
string="Bill Services", help="Bill Services", default=True
|
||||
)
|
||||
bill_rooms = fields.Boolean(string="Bill Rooms", help="Bill Rooms", default=True)
|
||||
deduct_down_payments = fields.Boolean(
|
||||
string="Deduct down payments", help="Deduct down payments", default=True
|
||||
)
|
||||
has_down_payments = fields.Boolean(
|
||||
string="Has down payments",
|
||||
help="Has down payments",
|
||||
readonly=True,
|
||||
default=lambda self: self._default_has_down_payment,
|
||||
)
|
||||
product_id = fields.Many2one(
|
||||
string="Down Payment Product",
|
||||
default=lambda self: self._default_product_id,
|
||||
comodel_name="product.product",
|
||||
domain=[("type", "=", "service")],
|
||||
)
|
||||
count = fields.Integer(
|
||||
string="Order Count",
|
||||
default=lambda self: self._count,
|
||||
)
|
||||
amount = fields.Float(
|
||||
string="Down Payment Amount",
|
||||
help="The percentage of amount to be invoiced in advance, taxes excluded.",
|
||||
digits="Account",
|
||||
)
|
||||
currency_id = fields.Many2one(
|
||||
string="Currency",
|
||||
help="Currency used in invoices",
|
||||
comodel_name="res.currency",
|
||||
default=lambda self: self._default_currency_id,
|
||||
)
|
||||
fixed_amount = fields.Monetary(
|
||||
string="Down Payment Amount (Fixed)",
|
||||
help="The fixed amount to be invoiced in advance, taxes excluded.",
|
||||
)
|
||||
deposit_account_id = fields.Many2one(
|
||||
string="Income Account",
|
||||
help="Account used for deposits",
|
||||
default=lambda self: self._default_deposit_account_id,
|
||||
comodel_name="account.account",
|
||||
domain=[("deprecated", "=", False)],
|
||||
)
|
||||
deposit_taxes_id = fields.Many2many(
|
||||
string="Customer Taxes",
|
||||
help="Taxes used for deposits",
|
||||
default=lambda self: self._default_deposit_taxes_id,
|
||||
comodel_name="account.tax",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _count(self):
|
||||
return len(self._context.get("active_ids", []))
|
||||
@@ -57,64 +129,17 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
folio = self.env["pms.folio"].browse(self._context.get("active_id", []))
|
||||
return folio.partner_invoice_ids[0]
|
||||
|
||||
partner_invoice_id = fields.Many2one(
|
||||
comodel_name="res.partner",
|
||||
string="Billing contact",
|
||||
default=_default_partner_invoice_id,
|
||||
)
|
||||
def _get_advance_details(self, order):
|
||||
context = {"lang": order.partner_id.lang}
|
||||
if self.advance_payment_method == "percentage":
|
||||
amount = order.amount_untaxed * self.amount / 100
|
||||
name = _("Down payment of %s%%") % (self.amount)
|
||||
else:
|
||||
amount = self.fixed_amount
|
||||
name = _("Down Payment")
|
||||
del context
|
||||
|
||||
advance_payment_method = fields.Selection(
|
||||
[
|
||||
("delivered", "Regular invoice"),
|
||||
("percentage", "Down payment (percentage)"),
|
||||
("fixed", "Down payment (fixed amount)"),
|
||||
],
|
||||
string="Create Invoice",
|
||||
default="delivered",
|
||||
required=True,
|
||||
help="A standard invoice is issued with all the order \
|
||||
lines ready for invoicing, \
|
||||
according to their invoicing policy \
|
||||
(based on ordered or delivered quantity).",
|
||||
)
|
||||
bill_services = fields.Boolean("Bill Services", default=True)
|
||||
bill_rooms = fields.Boolean("Bill Rooms", default=True)
|
||||
deduct_down_payments = fields.Boolean("Deduct down payments", default=True)
|
||||
has_down_payments = fields.Boolean(
|
||||
"Has down payments", default=_default_has_down_payment, readonly=True
|
||||
)
|
||||
product_id = fields.Many2one(
|
||||
"product.product",
|
||||
string="Down Payment Product",
|
||||
domain=[("type", "=", "service")],
|
||||
default=_default_product_id,
|
||||
)
|
||||
count = fields.Integer(default=_count, string="Order Count")
|
||||
amount = fields.Float(
|
||||
"Down Payment Amount",
|
||||
digits="Account",
|
||||
help="The percentage of amount to be invoiced in advance, taxes excluded.",
|
||||
)
|
||||
currency_id = fields.Many2one(
|
||||
"res.currency", string="Currency", default=_default_currency_id
|
||||
)
|
||||
fixed_amount = fields.Monetary(
|
||||
"Down Payment Amount (Fixed)",
|
||||
help="The fixed amount to be invoiced in advance, taxes excluded.",
|
||||
)
|
||||
deposit_account_id = fields.Many2one(
|
||||
"account.account",
|
||||
string="Income Account",
|
||||
domain=[("deprecated", "=", False)],
|
||||
help="Account used for deposits",
|
||||
default=_default_deposit_account_id,
|
||||
)
|
||||
deposit_taxes_id = fields.Many2many(
|
||||
"account.tax",
|
||||
string="Customer Taxes",
|
||||
help="Taxes used for deposits",
|
||||
default=_default_deposit_taxes_id,
|
||||
)
|
||||
return amount, name
|
||||
|
||||
@api.onchange("advance_payment_method")
|
||||
def onchange_advance_payment_method(self):
|
||||
@@ -161,18 +186,6 @@ class FolioAdvancePaymentInv(models.TransientModel):
|
||||
|
||||
return invoice_vals
|
||||
|
||||
def _get_advance_details(self, order):
|
||||
context = {"lang": order.partner_id.lang}
|
||||
if self.advance_payment_method == "percentage":
|
||||
amount = order.amount_untaxed * self.amount / 100
|
||||
name = _("Down payment of %s%%") % (self.amount)
|
||||
else:
|
||||
amount = self.fixed_amount
|
||||
name = _("Down Payment")
|
||||
del context
|
||||
|
||||
return amount, name
|
||||
|
||||
def _create_invoice(self, order, line, amount):
|
||||
if (self.advance_payment_method == "percentage" and self.amount <= 0.00) or (
|
||||
self.advance_payment_method == "fixed" and self.fixed_amount <= 0.00
|
||||
|
||||
@@ -18,17 +18,17 @@ class AdvancedFiltersWizard(models.TransientModel):
|
||||
_description = "Wizard for advanced filters"
|
||||
|
||||
pms_model_id = fields.Many2one(
|
||||
"ir.model",
|
||||
string="Recipients Model",
|
||||
ondelete="cascade",
|
||||
required=True,
|
||||
domain=[("model", "in", PMS_BUSINESS_MODELS)],
|
||||
default=lambda self: self.env.ref("pms.model_pms_reservation").id,
|
||||
comodel_name="ir.model",
|
||||
domain=[("model", "in", PMS_BUSINESS_MODELS)],
|
||||
ondelete="cascade",
|
||||
)
|
||||
pms_model_name = fields.Char(
|
||||
string="Recipients Model Name",
|
||||
related="pms_model_id.model",
|
||||
readonly=True,
|
||||
related="pms_model_id.model",
|
||||
related_sudo=True,
|
||||
)
|
||||
pms_domain = fields.Char(string="Domain")
|
||||
|
||||
@@ -11,70 +11,89 @@ class FolioWizard(models.TransientModel):
|
||||
)
|
||||
_check_pms_properties_auto = True
|
||||
|
||||
# Fields declaration
|
||||
start_date = fields.Date(
|
||||
string="From:",
|
||||
help="Start date for creation of reservations and folios",
|
||||
required=True,
|
||||
)
|
||||
end_date = fields.Date(
|
||||
string="To:",
|
||||
help="End date for creation of reservations and folios",
|
||||
required=True,
|
||||
)
|
||||
pricelist_id = fields.Many2one(
|
||||
comodel_name="product.pricelist",
|
||||
string="Pricelist",
|
||||
compute="_compute_pricelist_id",
|
||||
store=True,
|
||||
help="Pricelist applied in folio",
|
||||
readonly=False,
|
||||
store=True,
|
||||
comodel_name="product.pricelist",
|
||||
compute="_compute_pricelist_id",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
pms_property_id = fields.Many2one(
|
||||
comodel_name="pms.property",
|
||||
string="Property",
|
||||
help="Property to which the folio belongs",
|
||||
default=lambda self: self._default_pms_property_id(),
|
||||
comodel_name="pms.property",
|
||||
)
|
||||
segmentation_ids = fields.Many2many(
|
||||
"res.partner.category", string="Segmentation", ondelete="restrict"
|
||||
string="Segmentation",
|
||||
help="Partner Tags",
|
||||
ondelete="restrict",
|
||||
comodel_name="res.partner.category",
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
"res.partner",
|
||||
string="Partner",
|
||||
help="Partner who made the reservation",
|
||||
comodel_name="res.partner",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
folio_id = fields.Many2one(
|
||||
"pms.folio",
|
||||
string="Folio",
|
||||
help="Folio in which are included new reservations",
|
||||
comodel_name="pms.folio",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
availability_results = fields.One2many(
|
||||
strign="Availability Results",
|
||||
help="Availability Results",
|
||||
readonly=False,
|
||||
store=True,
|
||||
comodel_name="pms.folio.availability.wizard",
|
||||
inverse_name="folio_wizard_id",
|
||||
compute="_compute_availability_results",
|
||||
store=True,
|
||||
readonly=False,
|
||||
check_pms_properties=True,
|
||||
)
|
||||
agency_id = fields.Many2one(
|
||||
string="Agency",
|
||||
help="Agency that made the reservation",
|
||||
comodel_name="res.partner",
|
||||
ondelete="restrict",
|
||||
domain=[("is_agency", "=", True)],
|
||||
ondelete="restrict",
|
||||
)
|
||||
channel_type_id = fields.Many2one(
|
||||
string="Direct Sale Channel",
|
||||
help="Sales Channel through which the reservation was managed",
|
||||
readonly=False,
|
||||
store=True,
|
||||
comodel_name="pms.sale.channel",
|
||||
domain=[("channel_type", "=", "direct")],
|
||||
compute="_compute_channel_type_id",
|
||||
ondelete="restrict",
|
||||
compute="_compute_channel_type_id",
|
||||
)
|
||||
total_price_folio = fields.Float(
|
||||
string="Total Price", compute="_compute_total_price_folio"
|
||||
string="Total Price",
|
||||
help="Total price of folio with taxes",
|
||||
compute="_compute_total_price_folio",
|
||||
)
|
||||
discount = fields.Float(
|
||||
string="Discount",
|
||||
help="Discount that be applied in total price",
|
||||
default=0,
|
||||
)
|
||||
can_create_folio = fields.Boolean(compute="_compute_can_create_folio")
|
||||
can_create_folio = fields.Boolean(
|
||||
string="Can create folio", compute="_compute_can_create_folio"
|
||||
)
|
||||
|
||||
def _default_pms_property_id(self):
|
||||
if self._context.get("default_folio_id"):
|
||||
@@ -164,7 +183,6 @@ class FolioWizard(models.TransientModel):
|
||||
key=lambda s: s.num_rooms_available, reverse=True
|
||||
)
|
||||
|
||||
# actions
|
||||
def create_folio(self):
|
||||
for record in self:
|
||||
if not record.folio_id:
|
||||
|
||||
@@ -18,51 +18,63 @@ class AvailabilityWizard(models.TransientModel):
|
||||
_name = "pms.folio.availability.wizard"
|
||||
_check_pms_properties_auto = True
|
||||
|
||||
# Fields declarations
|
||||
folio_wizard_id = fields.Many2one(
|
||||
string="Folio Wizard ID",
|
||||
comodel_name="pms.folio.wizard",
|
||||
)
|
||||
checkin = fields.Date(
|
||||
string="From:",
|
||||
help="Date Reservation starts ",
|
||||
required=True,
|
||||
)
|
||||
checkout = fields.Date(
|
||||
string="To:",
|
||||
help="Date Reservation ends",
|
||||
required=True,
|
||||
)
|
||||
room_type_id = fields.Many2one(
|
||||
string="Room Type",
|
||||
help="Room Type reserved",
|
||||
comodel_name="pms.room.type",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
|
||||
num_rooms_available = fields.Integer(
|
||||
string="Available rooms",
|
||||
compute="_compute_num_rooms_available",
|
||||
help="Number of rooms that are available",
|
||||
store="true",
|
||||
compute="_compute_num_rooms_available",
|
||||
)
|
||||
num_rooms_selected = fields.Many2one(
|
||||
string="Selected rooms",
|
||||
readonly=False,
|
||||
store=True,
|
||||
comodel_name="pms.num.rooms.selection",
|
||||
inverse_name="folio_wizard_id",
|
||||
string="Selected rooms",
|
||||
compute="_compute_num_rooms_selected",
|
||||
store=True,
|
||||
readonly=False,
|
||||
domain="[('value', '<=', num_rooms_available), "
|
||||
"('room_type_id', '=', room_type_id)]",
|
||||
compute="_compute_num_rooms_selected",
|
||||
)
|
||||
value_num_rooms_selected = fields.Integer(
|
||||
compute="_compute_value_num_rooms_selected",
|
||||
store=True,
|
||||
string="Number of Rooms Selected",
|
||||
readonly=False,
|
||||
store=True,
|
||||
compute="_compute_value_num_rooms_selected",
|
||||
)
|
||||
price_per_room = fields.Float(
|
||||
string="Price per room",
|
||||
help="Price per room in folio",
|
||||
compute="_compute_price_per_room",
|
||||
)
|
||||
price_total = fields.Float(string="Total price", compute="_compute_price_total")
|
||||
price_total = fields.Float(
|
||||
string="Total price",
|
||||
help="The total price in the folio",
|
||||
compute="_compute_price_total",
|
||||
)
|
||||
pms_property_id = fields.Many2one(
|
||||
related="folio_wizard_id.pms_property_id",
|
||||
string="Property",
|
||||
help="Propertiy with access to the element;",
|
||||
related="folio_wizard_id.pms_property_id",
|
||||
)
|
||||
board_service_room_id = fields.Many2one(
|
||||
string="Board Service",
|
||||
|
||||
@@ -6,30 +6,26 @@ class WizardFolioChanges(models.TransientModel):
|
||||
_name = "wizard.folio.changes"
|
||||
_description = "Folio Changes"
|
||||
|
||||
def _default_folio_id(self):
|
||||
folio_id = self._context.get("active_id")
|
||||
folio = self.env["pms.folio"].browse(folio_id)
|
||||
return folio
|
||||
|
||||
def _default_reservation_ids(self):
|
||||
folio_id = self._context.get("active_id")
|
||||
folio = self.env["pms.folio"].browse(folio_id)
|
||||
return folio.reservation_ids
|
||||
|
||||
folio_id = fields.Many2one(
|
||||
"pms.folio",
|
||||
string="Folio",
|
||||
default=_default_folio_id,
|
||||
default=lambda self: self._default_folio_id(),
|
||||
comodel_name="pms.folio",
|
||||
)
|
||||
reservation_ids = fields.Many2many(
|
||||
"pms.reservation",
|
||||
string="Reservations",
|
||||
default=_default_reservation_ids,
|
||||
default=lambda self: self._default_reservation_ids(),
|
||||
comodel_name="pms.reservation",
|
||||
relation="folio_changes_reservation_rel",
|
||||
column1="folio_changes_id",
|
||||
column2="reservation_ids",
|
||||
domain="[('id', 'in', allowed_reservation_ids)]",
|
||||
)
|
||||
allowed_reservation_ids = fields.Many2many(
|
||||
"pms.reservation",
|
||||
string="Allowed Reservations",
|
||||
comodel_name="pms.reservation",
|
||||
relation="folio_changes_allowed_reservation_rel",
|
||||
column1="folio_changes_id",
|
||||
column2="allowed_reservation_ids",
|
||||
compute="_compute_allowed_reservations",
|
||||
)
|
||||
new_price = fields.Float(
|
||||
@@ -71,6 +67,16 @@ class WizardFolioChanges(models.TransientModel):
|
||||
default=True,
|
||||
)
|
||||
|
||||
def _default_folio_id(self):
|
||||
folio_id = self._context.get("active_id")
|
||||
folio = self.env["pms.folio"].browse(folio_id)
|
||||
return folio
|
||||
|
||||
def _default_reservation_ids(self):
|
||||
folio_id = self._context.get("active_id")
|
||||
folio = self.env["pms.folio"].browse(folio_id)
|
||||
return folio.reservation_ids
|
||||
|
||||
@api.depends("folio_id")
|
||||
def _compute_allowed_reservations(self):
|
||||
self.ensure_one()
|
||||
|
||||
@@ -10,39 +10,37 @@ class AvailabilityWizard(models.TransientModel):
|
||||
_description = "Wizard for massive changes on Availability Plans & Pricelists."
|
||||
_check_pms_properties_auto = True
|
||||
|
||||
def _default_avail_readonly(self):
|
||||
return True if self._context.get("availability_plan_id") else False
|
||||
|
||||
def _default_pricelist_readonly(self):
|
||||
return True if self._context.get("pricelist_id") else False
|
||||
|
||||
# Fields declaration
|
||||
pms_property_ids = fields.Many2many(
|
||||
comodel_name="pms.property",
|
||||
string="Property",
|
||||
comodel_name="pms.property",
|
||||
default=lambda self: self.env["pms.property"].browse(
|
||||
self.env.user.get_active_property_ids()[0]
|
||||
),
|
||||
)
|
||||
massive_changes_on = fields.Selection(
|
||||
[("pricelist", "Pricelist"), ("availability_plan", "Availability Plan")],
|
||||
string="On",
|
||||
default="availability_plan",
|
||||
selection=[
|
||||
("pricelist", "Pricelist"),
|
||||
("availability_plan", "Availability Plan"),
|
||||
],
|
||||
required=True,
|
||||
default="availability_plan",
|
||||
)
|
||||
availability_plan_id = fields.Many2one(
|
||||
comodel_name="pms.availability.plan",
|
||||
string="Availability Plan to apply massive changes",
|
||||
comodel_name="pms.availability.plan",
|
||||
check_pms_properties=True,
|
||||
# can be setted by context from availability plan detail
|
||||
)
|
||||
pricelist_id = fields.Many2one(
|
||||
comodel_name="product.pricelist",
|
||||
string="Pricelist to apply massive changes",
|
||||
comodel_name="product.pricelist",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
allowed_pricelist_ids = fields.One2many(
|
||||
comodel_name="product.pricelist", compute="_compute_allowed_pricelist_ids"
|
||||
string="Allowed pricelists",
|
||||
comodel_name="product.pricelist",
|
||||
compute="_compute_allowed_pricelist_ids",
|
||||
)
|
||||
start_date = fields.Date(
|
||||
string="From",
|
||||
@@ -53,8 +51,8 @@ class AvailabilityWizard(models.TransientModel):
|
||||
required=True,
|
||||
)
|
||||
room_type_id = fields.Many2one(
|
||||
comodel_name="pms.room.type",
|
||||
string="Room Type",
|
||||
comodel_name="pms.room.type",
|
||||
check_pms_properties=True,
|
||||
)
|
||||
price = fields.Float(string="Price")
|
||||
@@ -176,31 +174,45 @@ class AvailabilityWizard(models.TransientModel):
|
||||
)
|
||||
|
||||
rules_to_overwrite = fields.One2many(
|
||||
string="Rule to Overwrite",
|
||||
readonly=True,
|
||||
store=False,
|
||||
comodel_name="pms.availability.plan.rule",
|
||||
compute="_compute_rules_to_overwrite",
|
||||
store=False,
|
||||
readonly=True,
|
||||
)
|
||||
pricelist_items_to_overwrite = fields.One2many(
|
||||
string="Pricelist Items to Override",
|
||||
readonly=True,
|
||||
store=False,
|
||||
comodel_name="product.pricelist.item",
|
||||
compute="_compute_pricelist_items_to_overwrite",
|
||||
store=False,
|
||||
readonly=True,
|
||||
)
|
||||
num_rules_to_overwrite = fields.Integer(
|
||||
string="Rules to overwrite on massive changes",
|
||||
compute="_compute_num_rules_to_overwrite",
|
||||
store=False,
|
||||
readonly=True,
|
||||
store=False,
|
||||
compute="_compute_num_rules_to_overwrite",
|
||||
)
|
||||
num_pricelist_items_to_overwrite = fields.Integer(
|
||||
string="Pricelist items to overwrite on massive changes",
|
||||
compute="_compute_num_pricelist_items_to_overwrite",
|
||||
store=False,
|
||||
readonly=True,
|
||||
store=False,
|
||||
)
|
||||
avail_readonly = fields.Boolean(default=_default_avail_readonly)
|
||||
pricelist_readonly = fields.Boolean(default=_default_pricelist_readonly)
|
||||
avail_readonly = fields.Boolean(
|
||||
string="Avialability Readonly",
|
||||
default=lambda self: self._default_avail_readonly(),
|
||||
)
|
||||
pricelist_readonly = fields.Boolean(
|
||||
string="Pricelist Readonly",
|
||||
default=lambda self: self._default_pricelist_readonly(),
|
||||
)
|
||||
|
||||
def _default_avail_readonly(self):
|
||||
return True if self._context.get("availability_plan_id") else False
|
||||
|
||||
def _default_pricelist_readonly(self):
|
||||
return True if self._context.get("pricelist_id") else False
|
||||
|
||||
@api.depends("massive_changes_on")
|
||||
def _compute_allowed_pricelist_ids(self):
|
||||
@@ -417,7 +429,6 @@ class AvailabilityWizard(models.TransientModel):
|
||||
)
|
||||
return domain_overwrite
|
||||
|
||||
# actions
|
||||
def apply_massive_changes(self):
|
||||
|
||||
for record in self:
|
||||
|
||||
@@ -11,35 +11,35 @@ class WizardPaymentFolio(models.TransientModel):
|
||||
_description = "Payments"
|
||||
|
||||
folio_id = fields.Many2one(
|
||||
"pms.folio",
|
||||
string="Folio",
|
||||
required=True,
|
||||
comodel_name="pms.folio",
|
||||
)
|
||||
reservation_ids = fields.Many2many(
|
||||
"pms.reservation",
|
||||
string="Reservations",
|
||||
comodel_name="pms.reservation",
|
||||
)
|
||||
service_ids = fields.Many2many(
|
||||
"pms.service",
|
||||
string="Services",
|
||||
comodel_name="pms.service",
|
||||
)
|
||||
payment_method_id = fields.Many2one(
|
||||
"account.journal",
|
||||
string="Payment Method",
|
||||
required=True,
|
||||
comodel_name="account.journal",
|
||||
domain="[('id', 'in', allowed_method_ids)]",
|
||||
)
|
||||
allowed_method_ids = fields.Many2many(
|
||||
"account.journal",
|
||||
"allowed_payment_journal_rel",
|
||||
"payment_id",
|
||||
"journal_id",
|
||||
compute="_compute_allowed_method_ids",
|
||||
store="True",
|
||||
comodel_name="account.journal",
|
||||
relation="allowed_payment_journal_rel",
|
||||
column1="payment_id",
|
||||
column2="journal_id",
|
||||
compute="_compute_allowed_method_ids",
|
||||
)
|
||||
amount = fields.Float("Amount", digits=("Product Price"))
|
||||
date = fields.Date("Date", default=fields.Date.context_today, required=True)
|
||||
partner_id = fields.Many2one("res.partner")
|
||||
amount = fields.Float(string="Amount", digits=("Product Price"))
|
||||
date = fields.Date(String="Date", required=True, default=fields.Date.context_today)
|
||||
partner_id = fields.Many2one(string="Partner", comodel_name="res.partner")
|
||||
|
||||
@api.depends("folio_id")
|
||||
def _compute_allowed_method_ids(self):
|
||||
|
||||
@@ -6,29 +6,30 @@ from odoo.exceptions import UserError
|
||||
|
||||
class ReservationSplitJoinSwapWizard(models.TransientModel):
|
||||
_name = "pms.reservation.split.join.swap.wizard"
|
||||
string = ("Operation",)
|
||||
help = ("Operation to be applied on the reservation",)
|
||||
operation = fields.Selection(
|
||||
[
|
||||
("swap", "Swap rooms"),
|
||||
("split", "Split reservation"),
|
||||
("join", "Join reservation"),
|
||||
],
|
||||
string="Operation",
|
||||
help="Operation to be applied on the reservation",
|
||||
default=lambda self: self._context.get("default_operation")
|
||||
if self._context.get("default_operation")
|
||||
else "swap",
|
||||
)
|
||||
reservation_id = fields.Many2one(
|
||||
string="Reservation",
|
||||
comodel_name="pms.reservation",
|
||||
default=lambda self: self.env["pms.reservation"]
|
||||
.browse(self._context.get("active_id"))
|
||||
.id
|
||||
if self._context.get("active_id")
|
||||
else False,
|
||||
comodel_name="pms.reservation",
|
||||
)
|
||||
checkin = fields.Date(
|
||||
string="Check In",
|
||||
help="Checkin in reservation",
|
||||
default=lambda self: self.env["pms.reservation"]
|
||||
.browse(self._context.get("active_id"))
|
||||
.checkin
|
||||
@@ -37,6 +38,7 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
|
||||
)
|
||||
checkout = fields.Date(
|
||||
string="Check Out",
|
||||
help="checkout in reservation",
|
||||
default=lambda self: self.env["pms.reservation"]
|
||||
.browse(self._context.get("active_id"))
|
||||
.checkout
|
||||
@@ -45,15 +47,13 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
|
||||
)
|
||||
reservations = fields.Many2many(
|
||||
string="Reservations",
|
||||
comodel_name="pms.reservation",
|
||||
compute="_compute_reservations",
|
||||
readonly=False,
|
||||
store=True,
|
||||
comodel_name="pms.reservation",
|
||||
compute="_compute_reservations",
|
||||
)
|
||||
room_source = fields.Many2one(
|
||||
string="Room Source",
|
||||
comodel_name="pms.room",
|
||||
domain="[('id', 'in', allowed_rooms_sources)]",
|
||||
default=lambda self: self.env["pms.reservation"]
|
||||
.browse(self._context.get("active_id"))
|
||||
.preferred_room_id
|
||||
@@ -62,6 +62,8 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
|
||||
.browse(self._context.get("active_id"))
|
||||
.splitted
|
||||
else False,
|
||||
comodel_name="pms.room",
|
||||
domain="[('id', 'in', allowed_rooms_sources)]",
|
||||
)
|
||||
room_target = fields.Many2one(
|
||||
string="Room Target",
|
||||
@@ -70,25 +72,26 @@ class ReservationSplitJoinSwapWizard(models.TransientModel):
|
||||
)
|
||||
allowed_rooms_sources = fields.Many2many(
|
||||
string="Allowed rooms source",
|
||||
store=True,
|
||||
readonly=False,
|
||||
comodel_name="pms.room",
|
||||
relation="pms_wizard_split_join_swap_reservation_rooms_source",
|
||||
column1="wizard_id",
|
||||
column2="room_id",
|
||||
compute="_compute_allowed_rooms_source",
|
||||
store=True,
|
||||
readonly=False,
|
||||
)
|
||||
allowed_rooms_target = fields.Many2many(
|
||||
string="Allowed rooms target",
|
||||
comodel_name="pms.room",
|
||||
store=True,
|
||||
readonly=False,
|
||||
relation="pms_wizard_split_join_swap_reservation_rooms_target",
|
||||
column1="wizard_id",
|
||||
column2="room_id",
|
||||
compute="_compute_allowed_rooms_target",
|
||||
store=True,
|
||||
readonly=False,
|
||||
)
|
||||
reservation_lines_to_change = fields.One2many(
|
||||
string="Reservations Lines To Change",
|
||||
comodel_name="pms.wizard.reservation.lines.split",
|
||||
inverse_name="reservation_wizard_id",
|
||||
compute="_compute_reservation_lines",
|
||||
@@ -306,6 +309,7 @@ class ReservationLinesToSplit(models.TransientModel):
|
||||
_name = "pms.wizard.reservation.lines.split"
|
||||
|
||||
reservation_wizard_id = fields.Many2one(
|
||||
string="Reservation Wizard",
|
||||
comodel_name="pms.reservation.split.join.swap.wizard",
|
||||
)
|
||||
date = fields.Date(
|
||||
@@ -319,9 +323,9 @@ class ReservationLinesToSplit(models.TransientModel):
|
||||
allowed_room_ids = fields.Many2many(
|
||||
string="Allowed Rooms",
|
||||
help="It contains all available rooms for this line",
|
||||
store=True,
|
||||
comodel_name="pms.room",
|
||||
compute="_compute_allowed_room_ids",
|
||||
store=True,
|
||||
# readonly=False
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user